Class: ScripTTY::Cursor
- Inherits:
-
Object
- Object
- ScripTTY::Cursor
- Defined in:
- lib/scriptty/cursor.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
-
#initialize ⇒ Cursor
constructor
A new instance of Cursor.
- #pos ⇒ Object
- #pos=(value) ⇒ Object
Constructor Details
#initialize ⇒ Cursor
Returns a new instance of Cursor.
22 23 24 25 |
# File 'lib/scriptty/cursor.rb', line 22 def initialize @row = 0 @column = 0 end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
21 22 23 |
# File 'lib/scriptty/cursor.rb', line 21 def column @column end |
#row ⇒ Object
Returns the value of attribute row.
21 22 23 |
# File 'lib/scriptty/cursor.rb', line 21 def row @row end |
Instance Method Details
#pos ⇒ Object
27 28 29 |
# File 'lib/scriptty/cursor.rb', line 27 def pos [@row, @column] end |
#pos=(value) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/scriptty/cursor.rb', line 31 def pos=(value) raise TypeError.new("must be 2-element array") unless value.is_a?(Array) and value.length == 2 @row, @column = value @row ||= 0 @column ||= 0 value end |