Module: Sashite::Feen::Dumper

Defined in:
lib/sashite/feen/dumper.rb,
lib/sashite/feen/dumper/style_turn.rb,
lib/sashite/feen/dumper/pieces_in_hand.rb,
lib/sashite/feen/dumper/piece_placement.rb

Overview

Dumper for FEEN (Forsyth–Edwards Enhanced Notation) positions.

Converts a Position object into its canonical FEEN string representation by delegating serialization to specialized dumpers for each component.

Defined Under Namespace

Modules: PiecePlacement, PiecesInHand, StyleTurn

Constant Summary collapse

FIELD_SEPARATOR =

Field separator in FEEN notation.

" "
FIELD_COUNT =

Number of fields in a FEEN string.

3

Class Method Summary collapse

Class Method Details

.dump(position) ⇒ String

Dump a Position object into its canonical FEEN string representation.

Generates a deterministic FEEN string from a position object. The same position will always produce the same canonical string.

Examples:

Dump a position to FEEN

feen_string = Dumper.dump(position)
# => "+rnbq+kbn+r/+p+p+p+p+p+p+p+p/8/8/8/8/+P+P+P+P+P+P+P+P/+RNBQ+KBN+R / C/c"

Parameters:

  • position (Position)

    A position object with placement, hands, and styles

Returns:

  • (String)

    Canonical FEEN notation string



33
34
35
36
37
38
39
40
41
# File 'lib/sashite/feen/dumper.rb', line 33

def self.dump(position)
  fields = [
    Dumper::PiecePlacement.dump(position.placement),
    Dumper::PiecesInHand.dump(position.hands),
    Dumper::StyleTurn.dump(position.styles)
  ]

  join_fields(fields)
end