Module: Sashite::Feen::Parser::StyleTurn Private

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

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Parser for FEEN Style-Turn field (Field 3).

The Style-Turn field encodes:

  • The native Piece Style associated with each Player Side

  • The identity of the Active Player

Format:

<ACTIVE-STYLE>/<INACTIVE-STYLE>

Where each STYLE is a valid SIN token (exactly one ASCII letter).

Side attribution (by case):

  • Uppercase (A-Z): Player Side first

  • Lowercase (a-z): Player Side second

Turn attribution (by position):

  • Left of /: Active Player

  • Right of /: Inactive Player

Examples:

StyleTurn.parse("C/c")
# => { active: <Sin::Identifier C>, inactive: <Sin::Identifier c> }

StyleTurn.parse("s/S")
# => { active: <Sin::Identifier s>, inactive: <Sin::Identifier S> }

See Also:

API:

  • private

Class Method Summary collapse

Class Method Details

.parse(input) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses a FEEN Style-Turn field string.

Parameters:

  • The Style-Turn field string

Returns:

  • A hash with :active and :inactive keys containing SIN identifiers

Raises:

  • If the input is not valid

API:

  • private



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sashite/feen/parser/style_turn.rb', line 47

def self.parse(input)
  validate_delimiter!(input)

  active_str, inactive_str = input.split(Constants::SEGMENT_SEPARATOR, -1)

  active = parse_style(active_str)
  inactive = parse_style(inactive_str)

  validate_opposite_case!(active, inactive)

  { active: active, inactive: inactive }
end