Class: VeryGood::Terminal
- Inherits:
-
Object
- Object
- VeryGood::Terminal
- Defined in:
- lib/very_good/terminal.rb
Instance Method Summary collapse
- #clear! ⇒ Object
-
#initialize(width:, height:) ⇒ Terminal
constructor
A new instance of Terminal.
- #move_cursor(x, y) ⇒ Object
- #state ⇒ Object
- #state=(other) ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(width:, height:) ⇒ Terminal
Returns a new instance of Terminal.
3 4 5 |
# File 'lib/very_good/terminal.rb', line 3 def initialize(width:, height:) @state = State.new(width: width, height: height) end |
Instance Method Details
#clear! ⇒ Object
28 29 30 |
# File 'lib/very_good/terminal.rb', line 28 def clear! output.write Ansi.clear end |
#move_cursor(x, y) ⇒ Object
32 33 34 |
# File 'lib/very_good/terminal.rb', line 32 def move_cursor(x, y) output.write Ansi.move_cursor(x, y) end |
#state ⇒ Object
7 8 9 |
# File 'lib/very_good/terminal.rb', line 7 def state @state end |
#state=(other) ⇒ Object
11 12 13 |
# File 'lib/very_good/terminal.rb', line 11 def state=(other) @state = other end |
#update! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/very_good/terminal.rb', line 15 def update! clear! move_cursor(0, 0) state.lines.each do |line| line.each do |cell| output.write(cell.char) end end move_cursor(state.cursor.x, state.cursor.y) end |