Module: Sashite::Pcn
- Defined in:
- lib/sashite/pcn.rb,
lib/sashite/pcn/game.rb,
lib/sashite/pcn/game/meta.rb,
lib/sashite/pcn/game/sides.rb,
lib/sashite/pcn/game/sides/player.rb
Overview
PCN (Portable Chess Notation) implementation for Ruby
Provides functionality for representing complete chess game records across variants using a comprehensive JSON-based format.
This implementation is strictly compliant with PCN Specification v1.0.0
Defined Under Namespace
Classes: Game
Class Method Summary collapse
-
.parse(hash) ⇒ Game
Parse a PCN document from a hash structure.
-
.valid?(hash) ⇒ Boolean
Validate a PCN document structure.
Class Method Details
.parse(hash) ⇒ Game
Parse a PCN document from a hash structure
36 37 38 |
# File 'lib/sashite/pcn.rb', line 36 def self.parse(hash) Game.new(**hash.transform_keys(&:to_sym)) end |
.valid?(hash) ⇒ Boolean
Validate a PCN document structure
48 49 50 51 52 53 54 55 56 |
# File 'lib/sashite/pcn.rb', line 48 def self.valid?(hash) return false unless hash.is_a?(::Hash) return false unless hash.key?("setup") || hash.key?(:setup) parse(hash) true rescue ::ArgumentError, ::TypeError false end |