lib/edl.rb in edl-0.0.7 vs lib/edl.rb in edl-0.0.8

- old
+ new

@@ -3,14 +3,15 @@ require 'stringio' require File.dirname(__FILE__) + '/edl/event' require File.dirname(__FILE__) + '/edl/transition' require File.dirname(__FILE__) + '/edl/timewarp' +require File.dirname(__FILE__) + '/edl/parser' # A simplistic EDL parser module EDL - VERSION = "0.0.7" + VERSION = "0.0.8" DEFAULT_FPS = 25.0 # Represents an EDL, is returned from the parser. Traditional operation is functional style, i.e. # edl.renumbered.without_transitions.without_generators class List < Array @@ -312,53 +313,7 @@ evt # FIXME - we dont need to return this is only used by tests end end #:startdoc: - - # Is used to parse an EDL - class Parser - - attr_reader :fps - - # Initialize an EDL parser. Pass the FPS to it, as the usual EDL does not contain any kind of reference - # to it's framerate - def initialize(with_fps = DEFAULT_FPS) - @fps = with_fps - end - - def get_matchers #:nodoc: - [ EventMatcher.new(@fps), EffectMatcher.new, NameMatcher.new, TimewarpMatcher.new(@fps), CommentMatcher.new ] - end - - # Parse a passed File or IO object line by line, or the whole string - def parse(io) - return parse(StringIO.new(io.to_s)) unless io.respond_to?(:eof?) - - stack, matchers = List.new, get_matchers - - at_line = 0 - until io.eof? - at_line += 1 - - current_line = io.gets.strip - m = matchers.find{|m| m.matches?(current_line) } - next unless m - - begin - m.apply(stack, current_line) - stack[-1].line_number = at_line if m.is_a?(EventMatcher) - rescue Matcher::ApplyError => e - STDERR.puts "Cannot parse #{current_line} - #{e}" - end - end - stack - end - - # Init a Timecode object from the passed elements with the passed framerate - def self.timecode_from_line_elements(elements, fps) #:nodoc: - args = (0..3).map{|_| elements.shift.to_i} + [fps.to_f] - Timecode.at(*args) - end - end end \ No newline at end of file