Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/acts_as_duration/core_ext.rb
Instance Method Summary collapse
- #hhmmss ⇒ Object (also: #hhmm)
Instance Method Details
#hhmmss ⇒ Object Also known as: hhmm
2 3 4 5 6 7 8 9 |
# File 'lib/acts_as_duration/core_ext.rb', line 2 def hhmmss n = 3 seconds = self.split(':', n).inject(0) do |result, element| n -= 1 result + element.to_i * 60**n end ActiveSupport::Duration.new(seconds, [[:seconds, seconds]]) end |