Class: Terminal::Process
- Inherits:
-
Object
- Object
- Terminal::Process
- Defined in:
- lib/asciinema/terminal.rb
Instance Method Summary collapse
-
#initialize(command) ⇒ Process
constructor
A new instance of Process.
- #read_line ⇒ Object
- #stop ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(command) ⇒ Process
Returns a new instance of Process.
45 46 47 |
# File 'lib/asciinema/terminal.rb', line 45 def initialize(command) @stdin, @stdout, @thread = Open3.popen2(command) end |
Instance Method Details
#read_line ⇒ Object
54 55 56 57 |
# File 'lib/asciinema/terminal.rb', line 54 def read_line raise "terminal died" unless @thread.alive? @stdout.readline.strip end |
#stop ⇒ Object
59 60 61 |
# File 'lib/asciinema/terminal.rb', line 59 def stop @stdin.close end |
#write(data) ⇒ Object
49 50 51 52 |
# File 'lib/asciinema/terminal.rb', line 49 def write(data) raise "terminal died" unless @thread.alive? @stdin.write(data) end |