Module: DurationInWords::Methods
- Extended by:
- Methods
- Included in:
- ActionView::Helpers::DurationHelper, Methods
- Defined in:
- lib/duration_in_words/methods.rb
Instance Method Summary collapse
Instance Method Details
#duration_in_words(duration, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/duration_in_words/methods.rb', line 7 def duration_in_words(duration, = {}) raise_type_error(duration) unless duration.is_a?(ActiveSupport::Duration) locale, scope = () parts = duration.parts if parts.empty? key = "seconds.#{duration.value == 1 ? 'one' : 'other'}" return I18n.t(key, count: duration.value, scope: scope, locale: locale) end sentencify(parts, scope, locale) end |