Class: Spud::Shell
- Inherits:
-
String
- Object
- String
- Spud::Shell
- Defined in:
- lib/shell.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(cmd, silent: false) ⇒ Shell
constructor
A new instance of Shell.
- #kill! ⇒ Object
Constructor Details
#initialize(cmd, silent: false) ⇒ Shell
Returns a new instance of Shell.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/shell.rb', line 7 def initialize(cmd, silent: false) @pid = nil @status = nil output = StringIO.new _, stdout, _, @thread = Open3.popen3(cmd) while line = stdout.gets puts line output.puts line end @status = $? super(output.string) end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/shell.rb', line 5 def status @status end |
Instance Method Details
#kill! ⇒ Object
22 23 24 25 |
# File 'lib/shell.rb', line 22 def kill! thread.kill thread.join end |