Module: Timecoder
- Defined in:
- lib/timecoder.rb,
lib/timecoder/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.seconds_to_timecode(total_seconds) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/timecoder.rb', line 18 def self.seconds_to_timecode(total_seconds) raise if !total_seconds.class.eql?(Fixnum) hours = seconds_to_hours(total_seconds) total_seconds -= hours_to_seconds(hours) minutes = seconds_to_minutes(total_seconds) total_seconds -= minutes_to_seconds(minutes) seconds = total_seconds timecode_str(hours, minutes, seconds) end |
.timecode_to_seconds(timecode) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/timecoder.rb', line 7 def self.timecode_to_seconds(timecode) timecode_split = timecode.split(":") raise if timecode_split.length != 3 hours = timecode.split(":")[0].to_i minutes = timecode.split(":")[1].to_i seconds = timecode.split(":")[2].to_i seconds + minutes_to_seconds(minutes) + hours_to_seconds(hours) end |