Class: Terminal::Process

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

Instance Method Summary collapse

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_lineObject



54
55
56
57
# File 'lib/asciinema/terminal.rb', line 54

def read_line
  raise "terminal died" unless @thread.alive?
  @stdout.readline.strip
end

#stopObject



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