Class: Ffmprb::Util::Reader
Instance Attribute Summary
Attributes inherited from Thread
Attributes included from ProcVis::Node
Instance Method Summary collapse
-
#initialize(input, store: false, log_with: nil, log_as: Logger::DEBUG) ⇒ 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
Methods included from ProcVis::Node
#proc_vis_edge, #proc_vis_name, #proc_vis_node
Constructor Details
#initialize(input, store: false, log_with: nil, log_as: Logger::DEBUG) ⇒ Reader
Returns a new instance of Reader.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ffmprb/util.rb', line 117 def initialize(input, store: false, log_with: nil, log_as: Logger::DEBUG) @output = '' @queue = Queue.new super "reader" do begin while s = input.gets Ffmprb.logger.log log_as, "#{log_with}: #{s.chomp}" if log_with @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
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/ffmprb/util.rb', line 133 def read case res = @queue.deq when Exception fail res when '' nil else res end end |