Module: Feen::Dumper::StyleTurn

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

Overview

Handles conversion of style turn data to FEEN notation string

Constant Summary collapse

ERRORS =

Error messages for validation

{
  invalid_type: "%s must be a String, got %s",
  empty_string: "%s cannot be empty",
  invalid_snn:  "%s must be valid SNN notation: %s",
  same_casing:  "One style must be uppercase and the other lowercase"
}.freeze

Class Method Summary collapse

Class Method Details

.dump(active_style, inactive_style) ⇒ String

Converts the active and inactive style identifiers to a FEEN-formatted style turn string

Examples:

Valid style turn

StyleTurn.dump("CHESS", "chess")
# => "CHESS/chess"

Valid style turn with variants

StyleTurn.dump("CHESS960", "makruk")
# => "CHESS960/makruk"

Invalid - same casing

StyleTurn.dump("CHESS", "MAKRUK")
# => ArgumentError: One style must be uppercase and the other lowercase

Parameters:

  • active_style (String)

    Identifier for the player to move and their style

  • inactive_style (String)

    Identifier for the opponent and their style

Returns:

  • (String)

    FEEN-formatted style turn string

Raises:

  • (ArgumentError)

    If the style identifiers are invalid



35
36
37
38
# File 'lib/feen/dumper/style_turn.rb', line 35

def self.dump(active_style, inactive_style)
  validate_styles(active_style, inactive_style)
  "#{active_style}/#{inactive_style}"
end