Class: Terminal
- Inherits:
-
Object
- Object
- Terminal
- Defined in:
- lib/asciinema/terminal.rb
Defined Under Namespace
Classes: Process
Constant Summary collapse
- BINARY_PATH =
BINARY_PATH = (File.dirname(__FILE__) + “/../../bin/” + “terminal”).to_s
'terminal'
Instance Method Summary collapse
- #cursor ⇒ Object
- #feed(data) ⇒ Object
-
#initialize(width, height) ⇒ Terminal
constructor
A new instance of Terminal.
- #release ⇒ Object
- #snapshot ⇒ Object
Constructor Details
#initialize(width, height) ⇒ Terminal
Returns a new instance of Terminal.
12 13 14 |
# File 'lib/asciinema/terminal.rb', line 12 def initialize(width, height) @process = Process.new("#{BINARY_PATH} #{width} #{height}") end |
Instance Method Details
#cursor ⇒ Object
28 29 30 31 32 33 |
# File 'lib/asciinema/terminal.rb', line 28 def cursor process.write("c\n") c = Yajl::Parser.new.parse(process.read_line) Cursor.new(c['x'], c['y'], c['visible']) end |
#feed(data) ⇒ Object
16 17 18 19 |
# File 'lib/asciinema/terminal.rb', line 16 def feed(data) process.write("d\n#{data.bytesize}\n") process.write(data) end |
#release ⇒ Object
35 36 37 |
# File 'lib/asciinema/terminal.rb', line 35 def release process.stop end |