Class: TTYString::Cursor
- Inherits:
-
Object
- Object
- TTYString::Cursor
- Defined in:
- lib/tty_string/cursor.rb
Overview
point on a screen. you can move it
Instance Attribute Summary collapse
-
#col ⇒ Object
Returns the value of attribute col.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
- #down(count = 1) ⇒ Object
-
#initialize(row = 0, col = 0) ⇒ Cursor
constructor
A new instance of Cursor.
- #left(count = 1) ⇒ Object
- #right(count = 1) ⇒ Object
- #to_ary ⇒ Object
- #up(count = 1) ⇒ Object
Constructor Details
#initialize(row = 0, col = 0) ⇒ Cursor
Returns a new instance of Cursor.
8 9 10 11 |
# File 'lib/tty_string/cursor.rb', line 8 def initialize(row = 0, col = 0) @row = row @col = col end |
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
6 7 8 |
# File 'lib/tty_string/cursor.rb', line 6 def col @col end |
#row ⇒ Object
Returns the value of attribute row.
6 7 8 |
# File 'lib/tty_string/cursor.rb', line 6 def row @row end |
Instance Method Details
#down(count = 1) ⇒ Object
31 32 33 |
# File 'lib/tty_string/cursor.rb', line 31 def down(count = 1) self.row += count end |
#left(count = 1) ⇒ Object
23 24 25 |
# File 'lib/tty_string/cursor.rb', line 23 def left(count = 1) self.col -= count end |
#right(count = 1) ⇒ Object
35 36 37 |
# File 'lib/tty_string/cursor.rb', line 35 def right(count = 1) self.col += count end |
#to_ary ⇒ Object
39 40 41 |
# File 'lib/tty_string/cursor.rb', line 39 def to_ary [row, col] end |
#up(count = 1) ⇒ Object
27 28 29 |
# File 'lib/tty_string/cursor.rb', line 27 def up(count = 1) self.row -= count end |