Class: EDL::TimewarpMatcher
Instance Attribute Summary collapse
-
#fps ⇒ Object
readonly
Returns the value of attribute fps.
Instance Method Summary collapse
- #apply(stack, line) ⇒ Object
-
#initialize(fps) ⇒ TimewarpMatcher
constructor
A new instance of TimewarpMatcher.
Methods inherited from Matcher
Constructor Details
#initialize(fps) ⇒ TimewarpMatcher
Returns a new instance of TimewarpMatcher.
210 211 212 213 |
# File 'lib/edl.rb', line 210 def initialize(fps) @fps = fps @regexp = /M2(\s+)(\w+)(\s+)(\-?\d+\.\d+)(\s+)(\d{1,2}):(\d{1,2}):(\d{1,2}):(\d{1,2})/ end |
Instance Attribute Details
#fps ⇒ Object (readonly)
Returns the value of attribute fps.
208 209 210 |
# File 'lib/edl.rb', line 208 def fps @fps end |
Instance Method Details
#apply(stack, line) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/edl.rb', line 215 def apply(stack, line) matches = line.scan(@regexp).flatten.map(&:strip).reject { |e| e.nil? || e.empty? } from_reel = matches.shift fps = matches.shift begin # FIXME tw_start_source_tc = Parser.timecode_from_line_elements(matches, @fps) rescue Timecode::Error => e raise ApplyError.new("Invalid TC in timewarp (#{e})", line) end evt_with_tw = stack.reverse.find { |e| e.src_start_tc == tw_start_source_tc && e.reel == from_reel } if evt_with_tw tw = Timewarp.new tw.actual_framerate = fps.to_f tw.clip = evt_with_tw evt_with_tw.timewarp = tw else raise ApplyError.new('Cannot find event marked by timewarp', line) end end |