Class: Mpg321::ProcessWrapper
- Inherits:
-
Object
- Object
- Mpg321::ProcessWrapper
- Defined in:
- lib/mpg321/process_wrapper.rb
Instance Method Summary collapse
-
#initialize ⇒ ProcessWrapper
constructor
A new instance of ProcessWrapper.
- #on(event, &block) ⇒ Object
- #quit ⇒ Object
- #send_command(command, *args) ⇒ Object
Constructor Details
#initialize ⇒ ProcessWrapper
Returns a new instance of ProcessWrapper.
5 6 7 8 9 10 |
# File 'lib/mpg321/process_wrapper.rb', line 5 def initialize spawn_mpg321 @callbacks = Hash.new { |h, e| h[e] = Array.new } @read_thr = async_handle_stdoe end |
Instance Method Details
#on(event, &block) ⇒ Object
16 17 18 |
# File 'lib/mpg321/process_wrapper.rb', line 16 def on(event, &block) @callbacks[event] << block end |
#quit ⇒ Object
20 21 22 23 24 |
# File 'lib/mpg321/process_wrapper.rb', line 20 def quit send_command 'Q' @read_thr.join @wait_thr.value end |
#send_command(command, *args) ⇒ Object
12 13 14 |
# File 'lib/mpg321/process_wrapper.rb', line 12 def send_command command, *args @stdin.puts [command, *(args.map(&:to_s))].join(' ') end |