diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-06 08:26:32 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-06 08:26:45 -0700 |
commit | 3a91d44eff00476e399b3246871f4760817ecf9e (patch) | |
tree | f357c2e506b2fd92d879c2de540f7beac143b679 /activesupport/lib | |
parent | 5edfc463484827df364a1e589677d5c84dfac282 (diff) | |
download | rails-3a91d44eff00476e399b3246871f4760817ecf9e.tar.gz rails-3a91d44eff00476e399b3246871f4760817ecf9e.tar.bz2 rails-3a91d44eff00476e399b3246871f4760817ecf9e.zip |
let ruby decompose the tuples in the iterator
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/duration.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 2cdc991120..a0139b7d8e 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -70,7 +70,7 @@ module ActiveSupport 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? |