Class: FEEN::Parser::Shape

Inherits:
Object
  • Object
show all
Defined in:
lib/feen/parser/shape.rb

Overview

The shape class.

Examples:

Parse the shape of a shogiban

Shape.new("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9").to_a # => [9, 9]

Instance Method Summary collapse

Constructor Details

#initialize(board) ⇒ Shape

Returns a new instance of Shape.

Parameters:

  • board (String)

    The flatten board.



11
12
13
# File 'lib/feen/parser/shape.rb', line 11

def initialize(board)
  @board = board
end

Instance Method Details

#to_aArray

Returns The size of each dimension of the board.

Returns:

  • (Array)

    The size of each dimension of the board.



16
17
18
# File 'lib/feen/parser/shape.rb', line 16

def to_a
  indexes(@board, @board.scan(%r{/+}).sort.fetch(-1))
end