Class: EDL::EventMatcher
Constant Summary collapse
- EVENT_PAT =
021 009 V C 00:39:04:21 00:39:05:09 01:00:26:17 01:00:27:05
/(\d+)(\s+)([^\s]+)(\s+)(\w+)(\s+)(\w+)(\s+)((\w+\s+)?)#{TC} #{TC} #{TC} #{TC}/
Instance Attribute Summary collapse
-
#fps ⇒ Object
readonly
Returns the value of attribute fps.
Instance Method Summary collapse
- #apply(stack, line) ⇒ Object
-
#initialize(some_fps) ⇒ EventMatcher
constructor
A new instance of EventMatcher.
Methods inherited from Matcher
Constructor Details
#initialize(some_fps) ⇒ EventMatcher
Returns a new instance of EventMatcher.
250 251 252 253 |
# File 'lib/edl.rb', line 250 def initialize(some_fps) super(EVENT_PAT) @fps = some_fps end |
Instance Attribute Details
#fps ⇒ Object (readonly)
Returns the value of attribute fps.
248 249 250 |
# File 'lib/edl.rb', line 248 def fps @fps end |
Instance Method Details
#apply(stack, line) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/edl.rb', line 255 def apply(stack, line) matches = line.scan(@regexp).shift props = {} # FIrst one is the event number props[:num] = matches.shift matches.shift # Then the reel props[:reel] = matches.shift matches.shift # Then the track props[:track] = matches.shift matches.shift # Then the type props[:transition] = matches.shift matches.shift # Then the optional generator group - skip for now if props[:transition] != 'C' props[:duration] = matches.shift.strip else matches.shift end matches.shift # Then the timecodes [:src_start_tc, :src_end_tc, :rec_start_tc, :rec_end_tc].each do |k| begin props[k] = EDL::Parser.timecode_from_line_elements(matches, @fps) rescue Timecode::Error => e raise ApplyError.new("Cannot parse timecode - #{e}", line) end end evt = Event.new transition_idx = props.delete(:transition) evt.transition = case transition_idx when 'C' nil when 'D' d = Dissolve.new d.duration = props.delete(:duration).to_i d when /W(\d+)/ w = Wipe.new w.duration = props.delete(:duration).to_i w.smpte_wipe_index = transition_idx.delete('W') w when 'K' k = Key.new k.duration = props.delete(:duration).to_i k else raise "Unknown transition type #{transition_idx}" end # Give a hint on the incoming clip as well if evt.transition && stack[-1] stack[-1].outgoing_transition_duration = evt.transition.duration end props.each_pair { |k, v| evt.send("#{k}=", v) } stack << evt evt # FIXME: - we dont need to return this is only used by tests end |