Class: ScripTTY::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/scriptty/cursor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCursor

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

#columnObject

Returns the value of attribute column.



21
22
23
# File 'lib/scriptty/cursor.rb', line 21

def column
  @column
end

#rowObject

Returns the value of attribute row.



21
22
23
# File 'lib/scriptty/cursor.rb', line 21

def row
  @row
end

Instance Method Details

#posObject



27
28
29
# File 'lib/scriptty/cursor.rb', line 27

def pos
  [@row, @column]
end

#pos=(value) ⇒ Object

Raises:

  • (TypeError)


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