Class: Flaky::Cmd

Inherits:
Object
  • Object
show all
Defined in:
lib/flaky/appium.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ Cmd

Returns a new instance of Cmd.



7
8
9
10
# File 'lib/flaky/appium.rb', line 7

def initialize cmd
  @pid, @in, @out, @err = POSIX::Spawn::popen4 cmd
  @in.close
end

Instance Attribute Details

#errObject (readonly)

Returns the value of attribute err.



5
6
7
# File 'lib/flaky/appium.rb', line 5

def err
  @err
end

#inObject (readonly)

Returns the value of attribute in.



5
6
7
# File 'lib/flaky/appium.rb', line 5

def in
  @in
end

#outObject (readonly)

Returns the value of attribute out.



5
6
7
# File 'lib/flaky/appium.rb', line 5

def out
  @out
end

#pidObject (readonly)

Returns the value of attribute pid.



5
6
7
# File 'lib/flaky/appium.rb', line 5

def pid
  @pid
end

Instance Method Details

#stopObject



12
13
14
15
16
17
18
19
# File 'lib/flaky/appium.rb', line 12

def stop
  [@in, @out, @err].each { |io| io.close unless io.nil? || io.closed? }
  begin
    Process.kill 'KILL', @pid
    Process.waitpid @pid
  rescue # no such process
  end
end