Class: FLV::Edit::Processor::Reader

Inherits:
Base
  • Object
show all
Defined in:
lib/flvedit/processor/reader.rb

Overview

Reader is a Processor class (see Base) which use options[:files] to generate its sources (instead of the passed source which should be nil)

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#clone, #process_all

Constructor Details

#initializeReader

Returns a new instance of Reader.

Raises:

  • (NotImplemented)


8
9
10
11
12
13
14
# File 'lib/flvedit/processor/reader.rb', line 8

def initialize(*)
  super
  raise "Invalid filenames: #{options[:files].inspect}" unless options[:files].all?
  raise "Please specify at least one filename" if options[:files].empty?
  raise NotImplemented, "Reader can't have a source (other than options[:files])" if source
  rewind_source
end

Instance Method Details

#eachObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/flvedit/processor/reader.rb', line 22

def each
  p "Opening #{@sources.first}"
  FLV::File.open(@sources.shift) do |f|
    @source = f
    begin
      super
    rescue EOFError
      p "*** Warning: unexpected EOF for file #{f.path}"
    end
  end
end

#each_sourceObject



16
17
18
19
20
# File 'lib/flvedit/processor/reader.rb', line 16

def each_source
  return to_enum(:each_source) unless block_given?
  rewind_source
  yield until @sources.empty?
end

#rewind_sourceObject



34
35
36
# File 'lib/flvedit/processor/reader.rb', line 34

def rewind_source
  @sources = options[:files].dup
end