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

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

Constant Summary

Constants inherited from Base

Base::ALL_EVENTS, Base::EVENT_TRIGGER, Base::EVENT_TRIGGER_LIST, Base::MAIN_EVENTS

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#absorb, #dispatch_chunk, #dispatch_chunks, #dispatch_instead, #each, #process_all, #stdout, #stop

Constructor Details

#initializeReader

Returns a new instance of Reader.



5
6
7
8
9
10
# File 'lib/flv/edit/processor/reader.rb', line 5

def initialize(*)
  super
  rewind
  raise "Oups, Filenames were #{@options[:files].inspect}" if @options[:files].include? nil
  raise "Please specify at least one filename" if @options[:files].empty?
end

Instance Method Details

#has_next_file?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/flv/edit/processor/reader.rb', line 12

def has_next_file?
  @to_process > 0
end

#process_next_fileObject

Raises:

  • (IndexError)


20
21
22
23
24
25
26
# File 'lib/flv/edit/processor/reader.rb', line 20

def process_next_file
  raise IndexError, "No more filenames to process" unless has_next_file?
  @to_process -= 1
  FLV::File.open(@options[:files][-1- @to_process]) do |f|
    dispatch_chunks(f)
  end
end

#rewindObject



16
17
18
# File 'lib/flv/edit/processor/reader.rb', line 16

def rewind
  @to_process = @options[:files].length
end