Class: Ffmprb::Util::Reader
Instance Attribute Summary
Attributes inherited from Thread
Instance Method Summary collapse
-
#initialize(input, store = false, log = nil) ⇒ Reader
constructor
A new instance of Reader.
- #read ⇒ Object
Methods inherited from Thread
#child_dies, #child_lives, join_children!, #join_children!, #live!, timeout_or_live
Constructor Details
#initialize(input, store = false, log = nil) ⇒ Reader
Returns a new instance of Reader.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/ffmprb/util.rb', line 100 def initialize(input, store=false, log=nil) @output = '' @queue = Queue.new super "reader" do begin while s = input.gets Ffmprb.logger.debug "#{log}: #{s.chomp}" if log @output << s if store end @queue.enq @output rescue Exception @queue.enq Error.new("Exception in a reader thread") end end end |
Instance Method Details
#read ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ffmprb/util.rb', line 116 def read case res = @queue.deq when Exception fail res when '' nil else res end end |