Method: Timecode#initialize

Defined in:
lib/timecode.rb

#initialize(total = 0, fps = DEFAULT_FPS, drop_frame = false) ⇒ Timecode

Initialize a new Timecode object with a certain amount of frames, a framerate and an optional drop frame flag will be interpreted as the total number of frames

Raises:



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/timecode.rb', line 97

def initialize(total = 0, fps = DEFAULT_FPS, drop_frame = false)
  raise WrongFramerate, "FPS cannot be zero" if fps.zero?
  self.class.check_framerate!(fps)
  # If total is a string, use parse
  raise RangeError, "Timecode cannot be negative" if total.to_i < 0
  # Always cast framerate to float, and num of frames to integer
  @total, @fps = total.to_i, fps.to_f
  @drop_frame = drop_frame
  @value = validate!
  freeze
end