class Rubykon::GTPCoordinateConverter
Constants
- X_CHARS
Public Class Methods
new(board)
click to toggle source
# File lib/rubykon/gtp_coordinate_converter.rb, line 6 def initialize(board) @board = board end
Public Instance Methods
from(string)
click to toggle source
# File lib/rubykon/gtp_coordinate_converter.rb, line 10 def from(string) x = string[0] y = string[1..-1] x_index = X_CHARS.index(x) + 1 y_index = @board.size - y.to_i + 1 @board.identifier_for(x_index, y_index) end
to(index)
click to toggle source
# File lib/rubykon/gtp_coordinate_converter.rb, line 18 def to(index) x, y = @board.x_y_from(index) x_char = X_CHARS[x - 1] y_index = @board.size - y + 1 "#{x_char}#{y_index}" end