Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/time_difference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def in_each_component
end]
end

def in_general
def in_general(precision: :seconds)
remaining = @time_diff
Hash[TIME_COMPONENTS.map do |time_component|
Hash[TIME_COMPONENTS[0..TIME_COMPONENTS.index(precision)].map do |time_component|
if remaining > 0
rounded_time_component = (remaining / 1.send(time_component).seconds).round(2).floor
remaining -= rounded_time_component.send(time_component)
Expand All @@ -58,9 +58,10 @@ def in_general
end]
end

def humanize
def humanize(precision: :seconds)
diff_parts = []
in_general.each do |part,quantity|

in_general(precision: precision).each do |part,quantity|
next if quantity <= 0
part = part.to_s.humanize

Expand Down
2 changes: 1 addition & 1 deletion time_difference.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.version = "0.7.0"
gem.license = 'MIT'

gem.add_runtime_dependency('activesupport', '~> 5.1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks unrelated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea.. but there was no need to hard code the activesupport version here, since this wont support rails 6 now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but it's better to make unrelated changes in separate PRs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.. i'll create seaprate PR then

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#51

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#52

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think that we can close this one in favor of these two.

Copy link

@AlexWayfer AlexWayfer Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, honestly, you could change this one to something main, like precision, left it without unrelated changes, like activesupport version, and create only one separate for your case, with this activesupport version change.

gem.add_runtime_dependency('activesupport')
gem.add_development_dependency('rspec', '~> 3.7.0')
gem.add_development_dependency('rake')

Expand Down