class TicTacToe::TUI::Cursor

Constants

X_MARGIN
X_SPACING
Y_MARGIN
Y_SPACING

Public Class Methods

new(window) click to toggle source
# File lib/tic_tac_toe/tui/cursor.rb, line 10
def initialize(window)
  @window = window
end

Public Instance Methods

update(field, hidden: false) click to toggle source
# File lib/tic_tac_toe/tui/cursor.rb, line 14
def update(field, hidden: false)
  update_position(field)
  update_visibility(hidden)
end

Private Instance Methods

update_position(field) click to toggle source
# File lib/tic_tac_toe/tui/cursor.rb, line 21
def update_position(field)
  x, y = field
  position = [x * X_SPACING + X_MARGIN, y * Y_SPACING + Y_MARGIN]
  @window.setpos(*position)
end
update_visibility(hidden) click to toggle source
# File lib/tic_tac_toe/tui/cursor.rb, line 27
def update_visibility(hidden)
  if hidden
    Curses.curs_set(0)
  end
end