Module: Qi::Styles
- Defined in:
- lib/qi/styles.rb
Overview
Pure validation function for player styles.
A style is a String label denoting a movement tradition or game
family (e.g., "C", "S", "X"). Semantic validation (e.g., SIN
compliance) is the responsibility of the encoding layer (FEEN, PON,
etc.).
Constant Summary collapse
- MAX_STYLE_BYTESIZE =
255
Class Method Summary collapse
-
.validate(side, style) ⇒ String
Validates a single player style and returns it.
Class Method Details
.validate(side, style) ⇒ String
Validates a single player style and returns it.
The style must not be nil, must be a String, and must not
exceed MAX_STYLE_BYTESIZE bytes. The validated value is
returned as-is (no coercion, no allocation).
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qi/styles.rb', line 42 def self.validate(side, style) if style.nil? raise ::ArgumentError, "#{side} player style must not be nil" end unless style.is_a?(::String) raise ::ArgumentError, "#{side} player style must be a String" end if style.bytesize > MAX_STYLE_BYTESIZE raise ::ArgumentError, "#{side} player style exceeds #{MAX_STYLE_BYTESIZE} bytes" end style end |