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

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

Overview

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

Converts a FEEN style-turn string into a Styles object, decoding game style identifiers and the active player indicator.

Constant Summary collapse

STYLE_SEPARATOR =

Style separator in style-turn field.

"/"

Class Method Summary collapse

Class Method Details

.parse(string) ⇒ Styles

Parse a FEEN style-turn string into a Styles object.

Examples:

Chess game, white to move

parse("C/c")  # => Styles.new(sin_C, sin_c)

Chess game, black to move

parse("c/C")  # => Styles.new(sin_c, sin_C)

Cross-style game, first player to move

parse("C/m")  # => Styles.new(sin_C, sin_m)

Parameters:

  • string (String)

    FEEN style-turn field string

Returns:

  • (Styles)

    Parsed styles object

Raises:



37
38
39
40
41
42
43
44
# File 'lib/sashite/feen/parser/style_turn.rb', line 37

def self.parse(string)
  active_str, inactive_str = split_styles(string)

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

  Styles.new(active, inactive)
end