Class: Wopen3::Result
- Inherits:
-
Object
- Object
- Wopen3::Result
- Defined in:
- lib/wopen3.rb
Overview
class Opener
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
86 87 88 |
# File 'lib/wopen3.rb', line 86 def args @args end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
86 87 88 |
# File 'lib/wopen3.rb', line 86 def status @status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
86 87 88 |
# File 'lib/wopen3.rb', line 86 def stderr @stderr end |
#stdout ⇒ Object (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
105 106 107 |
# File 'lib/wopen3.rb', line 105 def success? @status == 0 end |