Class: Sashite::Cpn::Generate

Inherits:
Object
  • Object
show all
Defined in:
lib/sashite/cpn.rb

Overview

Main class.

Instance Method Summary collapse

Constructor Details

#initialize(bool, indexes, squares, pieces) ⇒ Generate

Returns a new instance of Generate.

Parameters:

  • bool (Boolean)

    The turn to play.

  • indexes (Array)

    The shape of the board.

  • squares (Array)

    The board structure.

  • pieces (Array)

    The list of pieces in hand.



25
26
27
28
29
30
31
32
# File 'lib/sashite/cpn.rb', line 25

def initialize(bool, indexes, squares, pieces)
  fail LengthError unless indexes.inject(:*).to_i.equal?(squares.length)

  @turn           = Turn.new(bool)
  @shape          = Shape.new(*indexes)
  @position       = Position.new(*squares)
  @pieces_in_hand = PiecesInHand.new(*pieces)
end

Instance Method Details

#to_sString

Returns A CPN string.

Returns:

  • (String)

    A CPN string.



35
36
37
38
39
40
41
42
# File 'lib/sashite/cpn.rb', line 35

def to_s
  [
    @turn.to_s,
    @shape.to_s,
    @position.to_s,
    @pieces_in_hand.to_s
  ].join('--')
end