Module: Sashite::Cgsn
- Defined in:
- lib/sashite/cgsn.rb,
lib/sashite/cgsn/status.rb
Overview
CGSN (Chess Game Status Notation) implementation for Ruby
Provides functionality for working with rule-agnostic game status values for abstract strategy board games.
This implementation is strictly compliant with CGSN Specification v1.0.0
Defined Under Namespace
Classes: Status
Constant Summary collapse
- STATUSES =
Complete list of all defined CGSN status values
%w[ stale checkmate stalemate nomove bareking mareking insufficient resignation illegalmove timelimit movelimit repetition agreement ].freeze
- INFERABLE_STATUSES =
Statuses that can be inferred from position analysis
%w[ stale checkmate stalemate nomove bareking mareking insufficient ].freeze
- EXPLICIT_ONLY_STATUSES =
Statuses that require explicit declaration
%w[ resignation illegalmove timelimit movelimit repetition agreement ].freeze
Class Method Summary collapse
-
.explicit_only?(status) ⇒ Boolean
Check if a status requires explicit declaration.
-
.explicit_only_statuses ⇒ Array<String>
Get the list of explicit-only status values.
-
.inferable?(status) ⇒ Boolean
Check if a status can be inferred from position analysis.
-
.inferable_statuses ⇒ Array<String>
Get the list of inferable status values.
-
.parse(value) ⇒ Status
Parse a status value into a Status object.
-
.statuses ⇒ Array<String>
Get the list of all defined CGSN status values.
-
.valid?(value) ⇒ Boolean
Check if a string is a valid CGSN status value.
Class Method Details
.explicit_only?(status) ⇒ Boolean
Check if a status requires explicit declaration
110 111 112 113 114 115 |
# File 'lib/sashite/cgsn.rb', line 110 def self.explicit_only?(status) status_string = String(status) EXPLICIT_ONLY_STATUSES.include?(status_string) rescue ::TypeError false end |
.explicit_only_statuses ⇒ Array<String>
Get the list of explicit-only status values
146 147 148 |
# File 'lib/sashite/cgsn.rb', line 146 def self.explicit_only_statuses EXPLICIT_ONLY_STATUSES.dup end |
.inferable?(status) ⇒ Boolean
Check if a status can be inferred from position analysis
94 95 96 97 98 99 |
# File 'lib/sashite/cgsn.rb', line 94 def self.inferable?(status) status_string = String(status) INFERABLE_STATUSES.include?(status_string) rescue ::TypeError false end |
.inferable_statuses ⇒ Array<String>
Get the list of inferable status values
135 136 137 |
# File 'lib/sashite/cgsn.rb', line 135 def self.inferable_statuses INFERABLE_STATUSES.dup end |
.parse(value) ⇒ Status
Parse a status value into a Status object
81 82 83 |
# File 'lib/sashite/cgsn.rb', line 81 def self.parse(value) Status.new(value) end |
.statuses ⇒ Array<String>
Get the list of all defined CGSN status values
124 125 126 |
# File 'lib/sashite/cgsn.rb', line 124 def self.statuses STATUSES.dup end |
.valid?(value) ⇒ Boolean
Check if a string is a valid CGSN status value
64 65 66 67 68 69 |
# File 'lib/sashite/cgsn.rb', line 64 def self.valid?(value) status_string = String(value) STATUSES.include?(status_string) rescue ::TypeError false end |