Module: Feen::Parser::StyleTurn
- Defined in:
- lib/feen/parser/style_turn.rb
Overview
Handles parsing of the style turn section of a FEEN string
Constant Summary collapse
- ERRORS =
Error messages for style turn parsing
{ invalid_type: "Style turn must be a string, got %s", empty_string: "Style turn string cannot be empty", invalid_format: "Invalid style turn format. Expected format: UPPERCASE/lowercase or lowercase/UPPERCASE", invalid_snn: "Invalid SNN notation in style turn: %s" }.freeze
- VALID_STYLE_TURN_PATTERN =
Pattern matching the FEEN specification for style turn <style-turn> ::= <style-id-uppercase> “/” <style-id-lowercase>
| <style-id-lowercase> "/" <style-id-uppercase>
%r{ \A # Start of string (?: # Non-capturing group for alternatives (?<uppercase_first>[A-Z][A-Z0-9]*) # Named group: uppercase style identifier first / # Separator (?<lowercase_second>[a-z][a-z0-9]*) # Named group: lowercase style identifier second | # OR (?<lowercase_first>[a-z][a-z0-9]*) # Named group: lowercase style identifier first / # Separator (?<uppercase_second>[A-Z][A-Z0-9]*) # Named group: uppercase style identifier second ) \z # End of string }x
Class Method Summary collapse
-
.parse(style_turn_str) ⇒ Array<String>
Parses the style turn section of a FEEN string.
Class Method Details
.parse(style_turn_str) ⇒ Array<String>
Parses the style turn section of a FEEN string
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/feen/parser/style_turn.rb', line 51 def self.parse(style_turn_str) validate_input_type(style_turn_str) match = VALID_STYLE_TURN_PATTERN.match(style_turn_str) raise ::ArgumentError, ERRORS[:invalid_format] unless match style_identifiers = extract_style_identifiers(match) validate_snn_compliance(style_identifiers) style_identifiers end |