Module: Sashite::Feen::Parser Private
- Defined in:
- lib/sashite/feen/parser.rb,
lib/sashite/feen/parser/hands.rb,
lib/sashite/feen/parser/style_turn.rb,
lib/sashite/feen/parser/piece_placement.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 (Field Expression Encoding Notation) strings.
A FEEN string consists of three fields separated by single ASCII spaces:
<PIECE-PLACEMENT> <HANDS> <STYLE-TURN>
This parser validates the overall structure and delegates field-specific parsing to specialized sub-parsers.
Defined Under Namespace
Modules: Hands, PiecePlacement, StyleTurn
Constant Summary collapse
- LINE_FEED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
ASCII byte values for line break characters.
0x0A
- CARRIAGE_RETURN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0x0D
Class Method Summary collapse
-
.parse(input) ⇒ Hash
private
Parses a FEEN string into its components.
-
.valid?(input) ⇒ Boolean
private
Validates a FEEN string without raising an exception.
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 string into its components.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sashite/feen/parser.rb', line 37 def self.parse(input) validate_input!(input) fields = input.split(Constants::FIELD_SEPARATOR, -1) validate_field_count!(fields) piece_placement_str, hands_str, style_turn_str = fields { piece_placement: PiecePlacement.parse(piece_placement_str), hands: Hands.parse(hands_str), style_turn: StyleTurn.parse(style_turn_str) } end |
.valid?(input) ⇒ Boolean
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.
Validates a FEEN string without raising an exception.
56 57 58 59 60 61 62 63 |
# File 'lib/sashite/feen/parser.rb', line 56 def self.valid?(input) return false unless ::String === input parse(input) true rescue ::ArgumentError false end |