Skip to content

Commit

Permalink
let ruby decompose the tuples in the iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 6, 2012
1 parent 5edfc46 commit 3a91d44
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/duration.rb
Expand Up @@ -70,7 +70,7 @@ def ago(time = ::Time.current)
alias :until :ago

def inspect #:nodoc:
consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h }
consolidated = parts.inject(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }
parts = [:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
Expand Down

0 comments on commit 3a91d44

Please sign in to comment.