Module: HandBrake::DurationAsSeconds
Overview
Provides a #seconds method for an object which has a duration
property whose value is a string of the format "hh:mm:ss"
Instance Method Summary collapse
-
#seconds ⇒ Fixnum
The number of seconds described by the duration.
Instance Method Details
#seconds ⇒ Fixnum
The number of seconds described by the duration. E.g., if the
duration were "1:02:42"
, this method would return 3762
.
119 120 121 122 |
# File 'lib/handbrake/disc.rb', line 119 def seconds @seconds ||= duration.split(':').collect(&:to_i).reverse. inject([1, 0]) { |(m, sum), i| [m * 60, sum + i * m] }.last end |