Class: SystemTester::CommandHandler

Inherits:
Object
  • Object
show all
Defined in:
app/models/system_tester/command_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ CommandHandler

Returns a new instance of CommandHandler.



5
6
7
8
# File 'app/models/system_tester/command_handler.rb', line 5

def initialize(cmd)
  @cmd = cmd
  @status = nil
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'app/models/system_tester/command_handler.rb', line 4

def status
  @status
end

Instance Method Details

#run(&block) ⇒ Object



10
11
12
13
14
15
16
# File 'app/models/system_tester/command_handler.rb', line 10

def run(&block)
  pty do |r,w,pid|
    rescue_errno pid do
      yield r.getc until r.eof?
    end
  end
end

#run_each_line(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/models/system_tester/command_handler.rb', line 18

def run_each_line(&block)
  pty do |r,w,pid|
    rescue_errno pid do
      r.each do |line|
        yield line
      end
    end
  end
end