Class: Spud::Shell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statusObject

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