Class: Wopen3::Result

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

Overview

class Opener

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Result

Returns a new instance of Result.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/wopen3.rb', line 88

def initialize *args
  @args = args
  @stderr = ''
  @stdout = ''
  Wopen3.popen3 *args do |stdin, stdout, stderr|
    threads = []
    threads << Thread.new(stdout) do |out|
      out.each { |line| @stdout << line }
    end
    threads << Thread.new(stderr) do |err|
      err.each { |line| @stderr << line }
    end
    threads.each { |thread| thread.join }
  end
  @status = $?.exitstatus
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



86
87
88
# File 'lib/wopen3.rb', line 86

def args
  @args
end

#statusObject (readonly)

Returns the value of attribute status.



86
87
88
# File 'lib/wopen3.rb', line 86

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



86
87
88
# File 'lib/wopen3.rb', line 86

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



86
87
88
# File 'lib/wopen3.rb', line 86

def stdout
  @stdout
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/wopen3.rb', line 105

def success?
  @status == 0
end