method
inspect
v2.1.0 -
Show latest stable
- Class:
ActiveSupport::Duration
inspect(#:nodoc:)public
No documentation available.
# File activesupport/lib/active_support/duration.rb, line 66
def inspect #:nodoc:
consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h }
[:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
end.compact.to_sentence
end