Class: TTYString::Cursor

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

Overview

point on a screen. you can move it

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colObject

Returns the value of attribute col.



6
7
8
# File 'lib/tty_string/cursor.rb', line 6

def col
  @col
end

#rowObject

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_aryObject



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