sashite-cgsn 0.2.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +201 -0
- data/README.md +125 -118
- data/lib/sashite/cgsn.rb +112 -94
- metadata +10 -16
- data/LICENSE.md +0 -22
- data/lib/sashite/cgsn/status.rb +0 -85
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a4b0e4315400be9e2678b80d4ab0cc80376084f7884a6b2b83f90807a948fad
|
|
4
|
+
data.tar.gz: 3cd371946d9525c43335fc552383b349a96e18b6532f5e58997a7af9f61e84fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb1a3c4c580bbb1ba11692629e2288a4279cddd43d59341d72e7a4e65e4c932a02d918cfb6abf2a165f9e8ea482b44256b3e5a5665d3ec169f8f06a5f1983cd3
|
|
7
|
+
data.tar.gz: bb97f53eaf9f3818cd3c865ee773c8aab292e5bef628e3bd0ba77ccd3ce2c3eb919be41f288872cc93cd03af3d80aa3b28eff63f472d0919d79c7e61a1ef20e9
|
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Cyril Kato
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cgsn.rb
|
|
2
2
|
|
|
3
3
|
[](https://github.com/sashite/cgsn.rb/tags)
|
|
4
4
|
[](https://rubydoc.info/github/sashite/cgsn.rb/main)
|
|
5
|
-
](https://github.com/sashite/cgsn.rb/actions)
|
|
6
|
+
[](https://github.com/sashite/cgsn.rb/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
-
> **CGSN** (Chess Game Status Notation) implementation for
|
|
8
|
+
> **CGSN** (Chess Game Status Notation) implementation for Ruby.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Overview
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
This gem implements the [CGSN Specification v1.0.0](https://sashite.dev/specs/cgsn/1.0.0/), providing a minimal Ruby interface for status validation and categorization with immutable status objects.
|
|
12
|
+
This library implements the [CGSN Specification v1.0.0](https://sashite.dev/specs/cgsn/1.0.0/).
|
|
15
13
|
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
@@ -26,150 +24,159 @@ Or install manually:
|
|
|
26
24
|
gem install sashite-cgsn
|
|
27
25
|
```
|
|
28
26
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
CGSN status values are lowercase strings using underscore separators:
|
|
32
|
-
|
|
33
|
-
```ruby
|
|
34
|
-
"checkmate"
|
|
35
|
-
"bareking"
|
|
36
|
-
"timelimit"
|
|
37
|
-
"stale"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## API Reference
|
|
27
|
+
## Usage
|
|
41
28
|
|
|
42
|
-
###
|
|
29
|
+
### Parsing (String → Symbol)
|
|
43
30
|
|
|
44
|
-
|
|
31
|
+
Convert a CGSN string into a symbol.
|
|
45
32
|
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
```ruby
|
|
34
|
+
require "sashite/cgsn"
|
|
48
35
|
|
|
49
|
-
|
|
36
|
+
# Standard parsing (raises on error)
|
|
37
|
+
Sashite::Cgsn.parse("checkmate") # => :checkmate
|
|
38
|
+
Sashite::Cgsn.parse("resignation") # => :resignation
|
|
50
39
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* `#hash` - Hash value for use in collections
|
|
40
|
+
# Invalid input raises ArgumentError
|
|
41
|
+
Sashite::Cgsn.parse("invalid") # => raises ArgumentError
|
|
42
|
+
Sashite::Cgsn.parse("") # => raises ArgumentError
|
|
43
|
+
```
|
|
56
44
|
|
|
57
|
-
###
|
|
45
|
+
### Validation
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
```ruby
|
|
48
|
+
# Boolean check
|
|
49
|
+
Sashite::Cgsn.valid?("checkmate") # => true
|
|
50
|
+
Sashite::Cgsn.valid?("resignation") # => true
|
|
51
|
+
Sashite::Cgsn.valid?("invalid") # => false
|
|
52
|
+
Sashite::Cgsn.valid?("") # => false
|
|
53
|
+
Sashite::Cgsn.valid?(nil) # => false
|
|
54
|
+
```
|
|
60
55
|
|
|
61
|
-
|
|
56
|
+
### Classification
|
|
62
57
|
|
|
63
|
-
|
|
58
|
+
```ruby
|
|
59
|
+
# Position-inferable: can be determined from Position + Rule System
|
|
60
|
+
Sashite::Cgsn.inferable?(:checkmate) # => true
|
|
61
|
+
Sashite::Cgsn.inferable?(:stalemate) # => true
|
|
62
|
+
Sashite::Cgsn.inferable?(:repetition) # => false
|
|
63
|
+
|
|
64
|
+
# Explicit-only: requires external context (history, clocks, declarations)
|
|
65
|
+
Sashite::Cgsn.explicit_only?(:resignation) # => true
|
|
66
|
+
Sashite::Cgsn.explicit_only?(:timelimit) # => true
|
|
67
|
+
Sashite::Cgsn.explicit_only?(:checkmate) # => false
|
|
68
|
+
```
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
* `Sashite::Cgsn.explicit_only?(status)` - Check if status requires explicit declaration
|
|
70
|
+
### Accessing Statuses
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
```ruby
|
|
73
|
+
# All statuses (unordered)
|
|
74
|
+
Sashite::Cgsn.statuses
|
|
75
|
+
# => #<Set: {:check, :stale, :checkmate, :stalemate, :nomove, :bareking,
|
|
76
|
+
# :mareking, :insufficient, :resignation, :illegalmove, :timelimit,
|
|
77
|
+
# :movelimit, :repetition, :agreement}>
|
|
78
|
+
|
|
79
|
+
# Position-inferable statuses
|
|
80
|
+
Sashite::Cgsn.inferable_statuses
|
|
81
|
+
# => #<Set: {:check, :stale, :checkmate, :stalemate, :nomove, :bareking,
|
|
82
|
+
# :mareking, :insufficient}>
|
|
83
|
+
|
|
84
|
+
# Explicit-only statuses
|
|
85
|
+
Sashite::Cgsn.explicit_only_statuses
|
|
86
|
+
# => #<Set: {:resignation, :illegalmove, :timelimit, :movelimit, :repetition,
|
|
87
|
+
# :agreement}>
|
|
88
|
+
```
|
|
69
89
|
|
|
70
|
-
|
|
71
|
-
* `Sashite::Cgsn.inferable_statuses` - Array of position-derivable statuses
|
|
72
|
-
* `Sashite::Cgsn.explicit_only_statuses` - Array of statuses requiring explicit recording
|
|
90
|
+
## API Reference
|
|
73
91
|
|
|
74
92
|
### Constants
|
|
75
93
|
|
|
76
|
-
* `Sashite::Cgsn::STATUSES` - Frozen array of all defined status values
|
|
77
|
-
* `Sashite::Cgsn::INFERABLE_STATUSES` - Frozen array of inferable status values
|
|
78
|
-
* `Sashite::Cgsn::EXPLICIT_ONLY_STATUSES` - Frozen array of explicit-only status values
|
|
79
|
-
|
|
80
|
-
## Usage
|
|
81
|
-
|
|
82
|
-
### Object-Oriented Approach
|
|
83
|
-
|
|
84
94
|
```ruby
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
status = Sashite::Cgsn.parse("checkmate")
|
|
89
|
-
status.inferable? # => true
|
|
90
|
-
status.explicit_only? # => false
|
|
91
|
-
status.to_s # => "checkmate"
|
|
92
|
-
|
|
93
|
-
# Create from string
|
|
94
|
-
status = Sashite::Cgsn::Status.new("resignation")
|
|
95
|
-
status.inferable? # => false
|
|
96
|
-
status.explicit_only? # => true
|
|
97
|
-
|
|
98
|
-
# Immutable objects
|
|
99
|
-
status.frozen? # => true
|
|
95
|
+
Sashite::Cgsn::STATUSES # Set of all 14 status symbols
|
|
96
|
+
Sashite::Cgsn::INFERABLE_STATUSES # Set of 8 position-inferable symbols
|
|
97
|
+
Sashite::Cgsn::EXPLICIT_ONLY_STATUSES # Set of 6 explicit-only symbols
|
|
100
98
|
```
|
|
101
99
|
|
|
102
|
-
###
|
|
100
|
+
### Parsing
|
|
103
101
|
|
|
104
102
|
```ruby
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
#
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
Sashite::Cgsn.inferable?("stalemate") # => true
|
|
113
|
-
Sashite::Cgsn.explicit_only?("timelimit") # => true
|
|
114
|
-
|
|
115
|
-
# Get all statuses
|
|
116
|
-
Sashite::Cgsn.statuses
|
|
117
|
-
# => ["stale", "checkmate", "stalemate", ...]
|
|
103
|
+
# Parses a CGSN string into a symbol.
|
|
104
|
+
# Raises ArgumentError if the string is not valid.
|
|
105
|
+
#
|
|
106
|
+
# @param input [String] CGSN status string
|
|
107
|
+
# @return [Symbol]
|
|
108
|
+
# @raise [ArgumentError] if invalid
|
|
109
|
+
def Sashite::Cgsn.parse(input)
|
|
118
110
|
```
|
|
119
111
|
|
|
120
|
-
|
|
112
|
+
### Validation
|
|
121
113
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
114
|
+
```ruby
|
|
115
|
+
# Reports whether string is a valid CGSN status identifier.
|
|
116
|
+
#
|
|
117
|
+
# @param input [String] The value to check
|
|
118
|
+
# @return [Boolean]
|
|
119
|
+
def Sashite::Cgsn.valid?(input)
|
|
120
|
+
```
|
|
129
121
|
|
|
130
|
-
|
|
122
|
+
### Classification
|
|
131
123
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
```ruby
|
|
125
|
+
# Reports whether status is position-inferable.
|
|
126
|
+
#
|
|
127
|
+
# @param status [Symbol] The status to check
|
|
128
|
+
# @return [Boolean]
|
|
129
|
+
def Sashite::Cgsn.inferable?(status)
|
|
130
|
+
|
|
131
|
+
# Reports whether status is explicit-only.
|
|
132
|
+
#
|
|
133
|
+
# @param status [Symbol] The status to check
|
|
134
|
+
# @return [Boolean]
|
|
135
|
+
def Sashite::Cgsn.explicit_only?(status)
|
|
136
|
+
```
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
### Listing
|
|
137
139
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
```ruby
|
|
141
|
+
# Returns all CGSN v1.0.0 status symbols.
|
|
142
|
+
#
|
|
143
|
+
# @return [Set<Symbol>]
|
|
144
|
+
def Sashite::Cgsn.statuses
|
|
145
|
+
|
|
146
|
+
# Returns position-inferable status symbols.
|
|
147
|
+
#
|
|
148
|
+
# @return [Set<Symbol>]
|
|
149
|
+
def Sashite::Cgsn.inferable_statuses
|
|
150
|
+
|
|
151
|
+
# Returns explicit-only status symbols.
|
|
152
|
+
#
|
|
153
|
+
# @return [Set<Symbol>]
|
|
154
|
+
def Sashite::Cgsn.explicit_only_statuses
|
|
155
|
+
```
|
|
141
156
|
|
|
142
|
-
|
|
157
|
+
### Errors
|
|
143
158
|
|
|
144
|
-
|
|
145
|
-
# Clone the repository
|
|
146
|
-
git clone https://github.com/sashite/cgsn.rb.git
|
|
147
|
-
cd cgsn.rb
|
|
159
|
+
All parsing errors raise `ArgumentError` with descriptive messages:
|
|
148
160
|
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
| Message | Cause |
|
|
162
|
+
|---------|-------|
|
|
163
|
+
| `"invalid status"` | Input is not a valid CGSN status |
|
|
151
164
|
|
|
152
|
-
|
|
153
|
-
ruby test.rb
|
|
165
|
+
## Design Principles
|
|
154
166
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
167
|
+
- **Symbol-based**: Statuses represented as Ruby symbols for identity semantics
|
|
168
|
+
- **Set-based**: Unordered collections reflect vocabulary nature
|
|
169
|
+
- **Strict validation**: Only standard v1.0.0 vocabulary accepted
|
|
170
|
+
- **Rule-agnostic**: Records conditions without defining outcomes
|
|
171
|
+
- **Immutable constants**: All sets are frozen
|
|
172
|
+
- **No dependencies**: Pure Ruby standard library only
|
|
158
173
|
|
|
159
|
-
##
|
|
174
|
+
## Related Specifications
|
|
160
175
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
4. Ensure all tests pass (`ruby test.rb`)
|
|
165
|
-
5. Commit your changes (`git commit -am 'Add new feature'`)
|
|
166
|
-
6. Push to the branch (`git push origin feature/new-feature`)
|
|
167
|
-
7. Create a Pull Request
|
|
176
|
+
- [Game Protocol](https://sashite.dev/game-protocol/) — Conceptual foundation
|
|
177
|
+
- [CGSN Specification](https://sashite.dev/specs/cgsn/1.0.0/) — Official specification
|
|
178
|
+
- [CGSN Examples](https://sashite.dev/specs/cgsn/1.0.0/examples/) — Usage examples
|
|
168
179
|
|
|
169
180
|
## License
|
|
170
181
|
|
|
171
|
-
Available as open source under the [
|
|
172
|
-
|
|
173
|
-
## About
|
|
174
|
-
|
|
175
|
-
Maintained by [Sashité](https://sashite.com/) — promoting chess variants and sharing the beauty of board game cultures.
|
|
182
|
+
Available as open source under the [Apache License 2.0](https://opensource.org/licenses/Apache-2.0).
|
data/lib/sashite/cgsn.rb
CHANGED
|
@@ -1,150 +1,168 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require "set"
|
|
4
4
|
|
|
5
5
|
module Sashite
|
|
6
|
-
# CGSN (Chess Game Status Notation) implementation for Ruby
|
|
6
|
+
# CGSN (Chess Game Status Notation) implementation for Ruby.
|
|
7
7
|
#
|
|
8
|
-
# Provides
|
|
9
|
-
#
|
|
8
|
+
# Provides a rule-agnostic vocabulary for identifying game statuses
|
|
9
|
+
# in abstract strategy board games with symbol-based identifiers.
|
|
10
10
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
11
|
+
# @example Parsing
|
|
12
|
+
# Sashite::Cgsn.parse("checkmate") # => :checkmate
|
|
13
|
+
#
|
|
14
|
+
# @example Validation
|
|
15
|
+
# Sashite::Cgsn.valid?("checkmate") # => true
|
|
16
|
+
# Sashite::Cgsn.valid?("invalid") # => false
|
|
17
|
+
#
|
|
18
|
+
# @example Classification
|
|
19
|
+
# Sashite::Cgsn.inferable?(:checkmate) # => true
|
|
20
|
+
# Sashite::Cgsn.explicit_only?(:resignation) # => true
|
|
21
|
+
#
|
|
22
|
+
# @see https://sashite.dev/specs/cgsn/1.0.0/
|
|
13
23
|
module Cgsn
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
agreement
|
|
24
|
+
# Position-inferable status symbols.
|
|
25
|
+
#
|
|
26
|
+
# These can be determined from Position + Rule System alone.
|
|
27
|
+
#
|
|
28
|
+
# @return [Set<Symbol>] frozen set of inferable status symbols
|
|
29
|
+
INFERABLE_STATUSES = Set[
|
|
30
|
+
:check,
|
|
31
|
+
:stale,
|
|
32
|
+
:checkmate,
|
|
33
|
+
:stalemate,
|
|
34
|
+
:nomove,
|
|
35
|
+
:bareking,
|
|
36
|
+
:mareking,
|
|
37
|
+
:insufficient
|
|
29
38
|
].freeze
|
|
30
39
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
# Explicit-only status symbols.
|
|
41
|
+
#
|
|
42
|
+
# These require external context (history, clocks, declarations).
|
|
43
|
+
#
|
|
44
|
+
# @return [Set<Symbol>] frozen set of explicit-only status symbols
|
|
45
|
+
EXPLICIT_ONLY_STATUSES = Set[
|
|
46
|
+
:resignation,
|
|
47
|
+
:illegalmove,
|
|
48
|
+
:timelimit,
|
|
49
|
+
:movelimit,
|
|
50
|
+
:repetition,
|
|
51
|
+
:agreement
|
|
40
52
|
].freeze
|
|
41
53
|
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
timelimit
|
|
47
|
-
movelimit
|
|
48
|
-
repetition
|
|
49
|
-
agreement
|
|
50
|
-
].freeze
|
|
54
|
+
# All CGSN v1.0.0 status symbols.
|
|
55
|
+
#
|
|
56
|
+
# @return [Set<Symbol>] frozen set of all status symbols
|
|
57
|
+
STATUSES = (INFERABLE_STATUSES | EXPLICIT_ONLY_STATUSES).freeze
|
|
51
58
|
|
|
52
|
-
#
|
|
59
|
+
# Valid status strings for parsing (private implementation detail).
|
|
60
|
+
VALID_STRINGS = STATUSES.map(&:to_s).to_set.freeze
|
|
61
|
+
private_constant :VALID_STRINGS
|
|
62
|
+
|
|
63
|
+
# Parses a CGSN string into a symbol.
|
|
53
64
|
#
|
|
54
|
-
# @param
|
|
55
|
-
# @return [
|
|
65
|
+
# @param input [String] The CGSN status string to parse
|
|
66
|
+
# @return [Symbol] The corresponding status symbol
|
|
67
|
+
# @raise [ArgumentError] If the input is not a valid CGSN status
|
|
56
68
|
#
|
|
57
69
|
# @example
|
|
58
|
-
# Sashite::Cgsn.
|
|
59
|
-
# Sashite::Cgsn.
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
# Sashite::Cgsn.
|
|
63
|
-
# Sashite::Cgsn.
|
|
64
|
-
def self.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
false
|
|
70
|
+
# Sashite::Cgsn.parse("checkmate") # => :checkmate
|
|
71
|
+
# Sashite::Cgsn.parse("resignation") # => :resignation
|
|
72
|
+
#
|
|
73
|
+
# @example Invalid input
|
|
74
|
+
# Sashite::Cgsn.parse("invalid") # => raises ArgumentError
|
|
75
|
+
# Sashite::Cgsn.parse("") # => raises ArgumentError
|
|
76
|
+
def self.parse(input)
|
|
77
|
+
raise ::ArgumentError, "invalid status" unless valid?(input)
|
|
78
|
+
|
|
79
|
+
:"#{input}"
|
|
69
80
|
end
|
|
70
81
|
|
|
71
|
-
#
|
|
82
|
+
# Reports whether the input is a valid CGSN status string.
|
|
72
83
|
#
|
|
73
|
-
# @param
|
|
74
|
-
# @return [
|
|
75
|
-
# @raise [ArgumentError] if the status value is invalid
|
|
84
|
+
# @param input [Object] The value to check
|
|
85
|
+
# @return [Boolean] true if valid, false otherwise
|
|
76
86
|
#
|
|
77
87
|
# @example
|
|
78
|
-
# Sashite::Cgsn.
|
|
79
|
-
# Sashite::Cgsn.
|
|
80
|
-
# Sashite::Cgsn.
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
# Sashite::Cgsn.valid?("checkmate") # => true
|
|
89
|
+
# Sashite::Cgsn.valid?("resignation") # => true
|
|
90
|
+
# Sashite::Cgsn.valid?("invalid") # => false
|
|
91
|
+
# Sashite::Cgsn.valid?("") # => false
|
|
92
|
+
# Sashite::Cgsn.valid?(nil) # => false
|
|
93
|
+
def self.valid?(input)
|
|
94
|
+
return false unless ::String === input
|
|
95
|
+
|
|
96
|
+
VALID_STRINGS.include?(input)
|
|
83
97
|
end
|
|
84
98
|
|
|
85
|
-
#
|
|
99
|
+
# Reports whether the status is position-inferable.
|
|
86
100
|
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
101
|
+
# Position-inferable statuses can be determined from Position + Rule System
|
|
102
|
+
# without external context (history, clocks, declarations).
|
|
103
|
+
#
|
|
104
|
+
# @param status [Symbol] The status to check
|
|
105
|
+
# @return [Boolean] true if position-inferable, false otherwise
|
|
89
106
|
#
|
|
90
107
|
# @example
|
|
91
|
-
# Sashite::Cgsn.inferable?(
|
|
92
|
-
# Sashite::Cgsn.inferable?(
|
|
93
|
-
# Sashite::Cgsn.inferable?(
|
|
108
|
+
# Sashite::Cgsn.inferable?(:checkmate) # => true
|
|
109
|
+
# Sashite::Cgsn.inferable?(:stalemate) # => true
|
|
110
|
+
# Sashite::Cgsn.inferable?(:repetition) # => false
|
|
94
111
|
def self.inferable?(status)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
false
|
|
112
|
+
return false unless ::Symbol === status
|
|
113
|
+
|
|
114
|
+
INFERABLE_STATUSES.include?(status)
|
|
99
115
|
end
|
|
100
116
|
|
|
101
|
-
#
|
|
117
|
+
# Reports whether the status is explicit-only.
|
|
102
118
|
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
119
|
+
# Explicit-only statuses require external context (history, clocks,
|
|
120
|
+
# declarations) and cannot be derived from Position + Rule System alone.
|
|
121
|
+
#
|
|
122
|
+
# @param status [Symbol] The status to check
|
|
123
|
+
# @return [Boolean] true if explicit-only, false otherwise
|
|
105
124
|
#
|
|
106
125
|
# @example
|
|
107
|
-
# Sashite::Cgsn.explicit_only?(
|
|
108
|
-
# Sashite::Cgsn.explicit_only?(
|
|
109
|
-
# Sashite::Cgsn.explicit_only?(
|
|
126
|
+
# Sashite::Cgsn.explicit_only?(:resignation) # => true
|
|
127
|
+
# Sashite::Cgsn.explicit_only?(:timelimit) # => true
|
|
128
|
+
# Sashite::Cgsn.explicit_only?(:checkmate) # => false
|
|
110
129
|
def self.explicit_only?(status)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
false
|
|
130
|
+
return false unless ::Symbol === status
|
|
131
|
+
|
|
132
|
+
EXPLICIT_ONLY_STATUSES.include?(status)
|
|
115
133
|
end
|
|
116
134
|
|
|
117
|
-
#
|
|
135
|
+
# Returns all CGSN v1.0.0 status symbols.
|
|
118
136
|
#
|
|
119
|
-
# @return [
|
|
137
|
+
# @return [Set<Symbol>] frozen set of all status symbols
|
|
120
138
|
#
|
|
121
139
|
# @example
|
|
122
140
|
# Sashite::Cgsn.statuses
|
|
123
|
-
# # =>
|
|
141
|
+
# # => #<Set: {:check, :stale, :checkmate, ...}>
|
|
124
142
|
def self.statuses
|
|
125
|
-
STATUSES
|
|
143
|
+
STATUSES
|
|
126
144
|
end
|
|
127
145
|
|
|
128
|
-
#
|
|
146
|
+
# Returns position-inferable status symbols.
|
|
129
147
|
#
|
|
130
|
-
# @return [
|
|
148
|
+
# @return [Set<Symbol>] frozen set of inferable status symbols
|
|
131
149
|
#
|
|
132
150
|
# @example
|
|
133
151
|
# Sashite::Cgsn.inferable_statuses
|
|
134
|
-
# # =>
|
|
152
|
+
# # => #<Set: {:check, :stale, :checkmate, :stalemate, ...}>
|
|
135
153
|
def self.inferable_statuses
|
|
136
|
-
INFERABLE_STATUSES
|
|
154
|
+
INFERABLE_STATUSES
|
|
137
155
|
end
|
|
138
156
|
|
|
139
|
-
#
|
|
157
|
+
# Returns explicit-only status symbols.
|
|
140
158
|
#
|
|
141
|
-
# @return [
|
|
159
|
+
# @return [Set<Symbol>] frozen set of explicit-only status symbols
|
|
142
160
|
#
|
|
143
161
|
# @example
|
|
144
162
|
# Sashite::Cgsn.explicit_only_statuses
|
|
145
|
-
# # =>
|
|
163
|
+
# # => #<Set: {:resignation, :illegalmove, :timelimit, ...}>
|
|
146
164
|
def self.explicit_only_statuses
|
|
147
|
-
EXPLICIT_ONLY_STATUSES
|
|
165
|
+
EXPLICIT_ONLY_STATUSES
|
|
148
166
|
end
|
|
149
167
|
end
|
|
150
168
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sashite-cgsn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyril Kato
|
|
@@ -9,28 +9,21 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
a minimal Ruby interface featuring immutable status objects and functional programming principles.
|
|
16
|
-
CGSN defines standardized identifiers for terminal conditions (checkmate, stalemate, bareking,
|
|
17
|
-
mareking, insufficient), player actions (resignation, agreement, illegalmove), and temporal
|
|
18
|
-
constraints (timelimit, movelimit, repetition), enabling precise and portable status identification
|
|
19
|
-
across multiple games and variants. Perfect for game engines, notation systems, and hybrid gaming
|
|
20
|
-
platforms requiring consistent, rule-agnostic game state representation.
|
|
12
|
+
description: CGSN (Chess Game Status Notation) implementation for Ruby. Provides a
|
|
13
|
+
rule-agnostic vocabulary for identifying game statuses in abstract strategy board
|
|
14
|
+
games with symbol-based identifiers and immutable sets.
|
|
21
15
|
email: contact@cyril.email
|
|
22
16
|
executables: []
|
|
23
17
|
extensions: []
|
|
24
18
|
extra_rdoc_files: []
|
|
25
19
|
files:
|
|
26
|
-
- LICENSE
|
|
20
|
+
- LICENSE
|
|
27
21
|
- README.md
|
|
28
22
|
- lib/sashite-cgsn.rb
|
|
29
23
|
- lib/sashite/cgsn.rb
|
|
30
|
-
- lib/sashite/cgsn/status.rb
|
|
31
24
|
homepage: https://github.com/sashite/cgsn.rb
|
|
32
25
|
licenses:
|
|
33
|
-
-
|
|
26
|
+
- Apache-2.0
|
|
34
27
|
metadata:
|
|
35
28
|
bug_tracker_uri: https://github.com/sashite/cgsn.rb/issues
|
|
36
29
|
documentation_uri: https://rubydoc.info/github/sashite/cgsn.rb/main
|
|
@@ -38,6 +31,7 @@ metadata:
|
|
|
38
31
|
source_code_uri: https://github.com/sashite/cgsn.rb
|
|
39
32
|
specification_uri: https://sashite.dev/specs/cgsn/1.0.0/
|
|
40
33
|
wiki_uri: https://sashite.dev/specs/cgsn/1.0.0/examples/
|
|
34
|
+
funding_uri: https://github.com/sponsors/sashite
|
|
41
35
|
rubygems_mfa_required: 'true'
|
|
42
36
|
rdoc_options: []
|
|
43
37
|
require_paths:
|
|
@@ -53,8 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
53
47
|
- !ruby/object:Gem::Version
|
|
54
48
|
version: '0'
|
|
55
49
|
requirements: []
|
|
56
|
-
rubygems_version:
|
|
50
|
+
rubygems_version: 4.0.3
|
|
57
51
|
specification_version: 4
|
|
58
|
-
summary: CGSN (Chess Game Status Notation) implementation for Ruby with
|
|
59
|
-
status
|
|
52
|
+
summary: CGSN (Chess Game Status Notation) implementation for Ruby with symbol-based
|
|
53
|
+
status vocabulary
|
|
60
54
|
test_files: []
|
data/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2025 Cyril Kato
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/sashite/cgsn/status.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Sashite
|
|
4
|
-
module Cgsn
|
|
5
|
-
# Represents a status value in CGSN (Chess Game Status Notation) format.
|
|
6
|
-
#
|
|
7
|
-
# A status consists of a lowercase string with optional underscore separators.
|
|
8
|
-
# Each status represents an observable game state that can be recorded
|
|
9
|
-
# independently of competitive interpretation.
|
|
10
|
-
#
|
|
11
|
-
# All instances are immutable.
|
|
12
|
-
class Status
|
|
13
|
-
# Error message for invalid status values
|
|
14
|
-
ERROR_INVALID_STATUS = "Invalid CGSN status: %s"
|
|
15
|
-
|
|
16
|
-
# Create a new status instance
|
|
17
|
-
#
|
|
18
|
-
# @param value [String] status value
|
|
19
|
-
# @raise [ArgumentError] if the value is invalid
|
|
20
|
-
#
|
|
21
|
-
# @example
|
|
22
|
-
# Status.new("checkmate") # => #<Cgsn::Status value="checkmate">
|
|
23
|
-
# Status.new("resignation") # => #<Cgsn::Status value="resignation">
|
|
24
|
-
def initialize(value)
|
|
25
|
-
@value = String(value)
|
|
26
|
-
|
|
27
|
-
raise ::ArgumentError, format(ERROR_INVALID_STATUS, @value) unless Cgsn::STATUSES.include?(@value)
|
|
28
|
-
|
|
29
|
-
freeze
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Check if the status can be inferred from position analysis
|
|
33
|
-
#
|
|
34
|
-
# @return [Boolean] true if inferable
|
|
35
|
-
#
|
|
36
|
-
# @example
|
|
37
|
-
# Status.new("checkmate").inferable? # => true
|
|
38
|
-
# Status.new("resignation").inferable? # => false
|
|
39
|
-
def inferable?
|
|
40
|
-
Cgsn::INFERABLE_STATUSES.include?(@value)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Check if the status requires explicit declaration
|
|
44
|
-
#
|
|
45
|
-
# @return [Boolean] true if explicit-only
|
|
46
|
-
#
|
|
47
|
-
# @example
|
|
48
|
-
# Status.new("resignation").explicit_only? # => true
|
|
49
|
-
# Status.new("checkmate").explicit_only? # => false
|
|
50
|
-
def explicit_only?
|
|
51
|
-
Cgsn::EXPLICIT_ONLY_STATUSES.include?(@value)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Convert the status to its string representation
|
|
55
|
-
#
|
|
56
|
-
# @return [String] status value
|
|
57
|
-
#
|
|
58
|
-
# @example
|
|
59
|
-
# Status.new("checkmate").to_s # => "checkmate"
|
|
60
|
-
def to_s
|
|
61
|
-
@value
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Custom equality comparison
|
|
65
|
-
#
|
|
66
|
-
# @param other [Object] object to compare with
|
|
67
|
-
# @return [Boolean] true if statuses are equal
|
|
68
|
-
def ==(other)
|
|
69
|
-
return false unless other.is_a?(self.class)
|
|
70
|
-
|
|
71
|
-
to_s == other.to_s
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# Alias for == to ensure Set functionality works correctly
|
|
75
|
-
alias eql? ==
|
|
76
|
-
|
|
77
|
-
# Custom hash implementation for use in collections
|
|
78
|
-
#
|
|
79
|
-
# @return [Integer] hash value
|
|
80
|
-
def hash
|
|
81
|
-
[self.class, @value].hash
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|