module Gobgems::WithMovementOps

Public Instance Methods

__move_to__(position) click to toggle source
# File lib/gobgems/board.rb, line 18
def __move_to__(position)
  raise OutOfBoardError unless within_bounds? position
  @head_position = position
end
can_move?(direction) click to toggle source
# File lib/gobgems/board.rb, line 6
def can_move?(direction)
  within_bounds? next_position(direction)
end
move(direction) click to toggle source
# File lib/gobgems/board.rb, line 10
def move(direction)
  __move_to__ next_position(direction)
end
move_to_edge(direction) click to toggle source
# File lib/gobgems/board.rb, line 14
def move_to_edge(direction)
  move(direction) while can_move?(direction)
end

Private Instance Methods

next_position(direction) click to toggle source
# File lib/gobgems/board.rb, line 25
def next_position(direction)
  direction.call(*@head_position)
end