Module: Sashite::Feen::Dumper::StyleTurn

Defined in:
lib/sashite/feen/dumper/style_turn.rb

Overview

Dumper for the style-turn field (third field of FEEN).

Converts a Styles object into its FEEN string representation, encoding game styles and indicating the active player.

Constant Summary collapse

STYLE_SEPARATOR =

Style separator in style-turn field.

"/"

Class Method Summary collapse

Class Method Details

.dump(styles) ⇒ String

Dump a Styles object into its FEEN style-turn string.

Formats the active and inactive player styles with the active player’s style appearing first. The case of each style identifier indicates which player uses it (uppercase = first player, lowercase = second player).

Examples:

Chess game, white to move

dump(styles)
# => "C/c"

Chess game, black to move

dump(styles)
# => "c/C"

Cross-style game, first player to move

dump(styles)
# => "C/m"

Parameters:

  • styles (Styles)

    The styles object with active and inactive styles

Returns:

  • (String)

    FEEN style-turn field string



37
38
39
# File 'lib/sashite/feen/dumper/style_turn.rb', line 37

def self.dump(styles)
  "#{styles.active}#{STYLE_SEPARATOR}#{styles.inactive}"
end