Class: Tracetool::Pipe::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/tracetool/utils/pipe.rb

Overview

Executes shell command

Instance Method Summary collapse

Constructor Details

#initialize(cmd, *args) ⇒ Executor

Returns a new instance of Executor.



7
8
9
10
# File 'lib/tracetool/utils/pipe.rb', line 7

def initialize(cmd, *args)
  @cmd = cmd
  @args = args
end

Instance Method Details

#<<(args) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/tracetool/utils/pipe.rb', line 16

def <<(args)
  args = args.join("\n") if args.is_a? Array
  IO.popen(cmd, 'r+') do |io|
    io.write(args)
    io.close_write
    io.read.chomp
  end
end

#cmdObject



12
13
14
# File 'lib/tracetool/utils/pipe.rb', line 12

def cmd
  [@cmd, @args].flatten
end