Class: Tracetool::Pipe::Executor
- Inherits:
-
Object
- Object
- Tracetool::Pipe::Executor
- Defined in:
- lib/tracetool/utils/pipe.rb
Overview
Executes shell command
Instance Method Summary collapse
- #<<(args) ⇒ Object
- #cmd ⇒ Object
-
#initialize(cmd, *args) ⇒ Executor
constructor
A new instance of Executor.
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 |
#cmd ⇒ Object
12 13 14 |
# File 'lib/tracetool/utils/pipe.rb', line 12 def cmd [@cmd, @args].flatten end |