Class: Webcmd::CommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/webcmd/command_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ CommandRunner

Returns a new instance of CommandRunner.



3
4
5
# File 'lib/webcmd/command_runner.rb', line 3

def initialize(command)
  @command = command
end

Instance Method Details

#each(&block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/webcmd/command_runner.rb', line 7

def each(&block)
  IO.popen([shell_env, 'bash', '-l', err: [:child, :out]], 'w+') do |shell|
    shell.write @command
    shell.close_write
    shell.each_line(&block)
  end
end