Module: Sashite::Feen::Parser::Hands Private
- Defined in:
- lib/sashite/feen/parser/hands.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 Hands field (Field 2).
The Hands field encodes off-board pieces held by each player:
<FIRST-HAND>/<SECOND-HAND>
Each hand is a concatenation of hand items with no separators:
[<count>]<piece>
Where:
-
<piece> is a valid EPIN token
-
<count> is an optional multiplicity (≥ 2 if present, absent = 1)
Hand items MUST be in canonical order:
-
By multiplicity — descending (larger counts first)
-
By base letter — case-insensitive alphabetical order
-
By letter case — uppercase before lowercase
-
By state modifier —
-before ‘+` before none -
By terminal marker — absent before present
-
By derivation marker — absent before present
Class Method Summary collapse
-
.parse(input) ⇒ Hash
private
Parses a FEEN Hands field string.
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 Hands field string.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sashite/feen/parser/hands.rb', line 50 def self.parse(input) validate_delimiter!(input) first_str, second_str = input.split(Constants::SEGMENT_SEPARATOR, -1) first_items = parse_hand(first_str) second_items = parse_hand(second_str) validate_canonical_order!(first_items) validate_canonical_order!(second_items) { first: first_items, second: second_items } end |