sashite-sin 3.0.0 → 3.1.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 +1 -1
- data/README.md +19 -60
- data/lib/sashite/sin/constants.rb +6 -6
- data/lib/sashite/sin/errors/argument/messages.rb +2 -2
- data/lib/sashite/sin/identifier.rb +20 -81
- data/lib/sashite/sin/parser.rb +9 -9
- data/lib/sashite/sin.rb +8 -8
- data/lib/sashite-sin.rb +0 -11
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '080b65573c2e27e8efe5c2ed79009daf31124b35c88ddc7bbe4023e6fe553acf'
|
|
4
|
+
data.tar.gz: fc25ce0ac44111a41d764aa8badac8ca2727a163e00accd5d8bf52ca301198d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93caf9df6d423fa40562f43971b8ea1c1a0c1bba1d4de9d11ee59184d2906638e2d4aa25639ed40010090dfa2929a658e9ba52f714bb46d1616639b6f2983685
|
|
7
|
+
data.tar.gz: 3d8c978b778d1210e71c288a41daf9f80a750a5a1f975c22a1536f8499f280a7302f0a51c6641d72522b3cc18b88bca5bb94ab7fdac5f8c7de1920b5444fc700
|
data/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright 2025 Cyril Kato
|
|
189
|
+
Copyright 2025-2026 Cyril Kato
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/sashite/sin.rb/tags)
|
|
4
4
|
[](https://rubydoc.info/github/sashite/sin.rb/main)
|
|
5
|
-
[](https://github.com/sashite/sin.rb/actions)
|
|
6
6
|
[](https://github.com/sashite/sin.rb/raw/main/LICENSE)
|
|
7
7
|
|
|
8
8
|
> **SIN** (Style Identifier Notation) implementation for Ruby.
|
|
@@ -35,13 +35,13 @@ require "sashite/sin"
|
|
|
35
35
|
|
|
36
36
|
# Standard parsing (raises on error)
|
|
37
37
|
sin = Sashite::Sin.parse("C")
|
|
38
|
-
sin.
|
|
39
|
-
sin.side
|
|
38
|
+
sin.abbr # => :C
|
|
39
|
+
sin.side # => :first
|
|
40
40
|
|
|
41
41
|
# Lowercase indicates second player
|
|
42
42
|
sin = Sashite::Sin.parse("c")
|
|
43
|
-
sin.
|
|
44
|
-
sin.side
|
|
43
|
+
sin.abbr # => :C
|
|
44
|
+
sin.side # => :second
|
|
45
45
|
|
|
46
46
|
# Invalid input raises ArgumentError
|
|
47
47
|
Sashite::Sin.parse("") # => raises ArgumentError
|
|
@@ -72,34 +72,6 @@ Sashite::Sin.valid?("CC") # => false
|
|
|
72
72
|
Sashite::Sin.valid?("1") # => false
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
### Accessing Identifier Data
|
|
76
|
-
|
|
77
|
-
```ruby
|
|
78
|
-
sin = Sashite::Sin.parse("C")
|
|
79
|
-
|
|
80
|
-
# Get attributes
|
|
81
|
-
sin.style # => :C
|
|
82
|
-
sin.side # => :first
|
|
83
|
-
|
|
84
|
-
# Get string component
|
|
85
|
-
sin.letter # => "C"
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Transformations
|
|
89
|
-
|
|
90
|
-
All transformations return new immutable `Identifier` objects.
|
|
91
|
-
|
|
92
|
-
```ruby
|
|
93
|
-
sin = Sashite::Sin.parse("C")
|
|
94
|
-
|
|
95
|
-
# Side transformation
|
|
96
|
-
sin.flip.to_s # => "c"
|
|
97
|
-
|
|
98
|
-
# Attribute changes
|
|
99
|
-
sin.with_style(:S).to_s # => "S"
|
|
100
|
-
sin.with_side(:second).to_s # => "c"
|
|
101
|
-
```
|
|
102
|
-
|
|
103
75
|
### Queries
|
|
104
76
|
|
|
105
77
|
```ruby
|
|
@@ -111,8 +83,8 @@ sin.second_player? # => false
|
|
|
111
83
|
|
|
112
84
|
# Comparison queries
|
|
113
85
|
other = Sashite::Sin.parse("c")
|
|
114
|
-
sin.
|
|
115
|
-
sin.same_side?(other)
|
|
86
|
+
sin.same_abbr?(other) # => true
|
|
87
|
+
sin.same_side?(other) # => false
|
|
116
88
|
```
|
|
117
89
|
|
|
118
90
|
## API Reference
|
|
@@ -120,20 +92,20 @@ sin.same_side?(other) # => false
|
|
|
120
92
|
### Types
|
|
121
93
|
|
|
122
94
|
```ruby
|
|
123
|
-
# Identifier represents a parsed SIN identifier with
|
|
95
|
+
# Identifier represents a parsed SIN identifier with abbreviation and side.
|
|
124
96
|
class Sashite::Sin::Identifier
|
|
125
|
-
# Creates an Identifier from
|
|
97
|
+
# Creates an Identifier from abbreviation and side.
|
|
126
98
|
# Raises ArgumentError if attributes are invalid.
|
|
127
99
|
#
|
|
128
|
-
# @param
|
|
100
|
+
# @param abbr [Symbol] Style abbreviation (:A through :Z)
|
|
129
101
|
# @param side [Symbol] Player side (:first or :second)
|
|
130
102
|
# @return [Identifier]
|
|
131
|
-
def initialize(
|
|
103
|
+
def initialize(abbr, side)
|
|
132
104
|
|
|
133
|
-
# Returns the style as an uppercase symbol.
|
|
105
|
+
# Returns the style abbreviation as an uppercase symbol.
|
|
134
106
|
#
|
|
135
107
|
# @return [Symbol]
|
|
136
|
-
def
|
|
108
|
+
def abbr
|
|
137
109
|
|
|
138
110
|
# Returns the player side.
|
|
139
111
|
#
|
|
@@ -150,8 +122,8 @@ end
|
|
|
150
122
|
### Constants
|
|
151
123
|
|
|
152
124
|
```ruby
|
|
153
|
-
Sashite::Sin::Identifier::
|
|
154
|
-
Sashite::Sin::Identifier::VALID_SIDES
|
|
125
|
+
Sashite::Sin::Identifier::VALID_ABBRS # => [:A, :B, ..., :Z]
|
|
126
|
+
Sashite::Sin::Identifier::VALID_SIDES # => [:first, :second]
|
|
155
127
|
```
|
|
156
128
|
|
|
157
129
|
### Parsing
|
|
@@ -176,19 +148,6 @@ def Sashite::Sin.parse(string)
|
|
|
176
148
|
def Sashite::Sin.valid?(string)
|
|
177
149
|
```
|
|
178
150
|
|
|
179
|
-
### Transformations
|
|
180
|
-
|
|
181
|
-
All transformations return new `Sashite::Sin::Identifier` objects:
|
|
182
|
-
|
|
183
|
-
```ruby
|
|
184
|
-
# Side transformation
|
|
185
|
-
def flip # => Identifier
|
|
186
|
-
|
|
187
|
-
# Attribute changes
|
|
188
|
-
def with_style(style) # => Identifier
|
|
189
|
-
def with_side(side) # => Identifier
|
|
190
|
-
```
|
|
191
|
-
|
|
192
151
|
### Queries
|
|
193
152
|
|
|
194
153
|
```ruby
|
|
@@ -197,8 +156,8 @@ def first_player? # => Boolean
|
|
|
197
156
|
def second_player? # => Boolean
|
|
198
157
|
|
|
199
158
|
# Comparison queries
|
|
200
|
-
def
|
|
201
|
-
def same_side?(other)
|
|
159
|
+
def same_abbr?(other) # => Boolean
|
|
160
|
+
def same_side?(other) # => Boolean
|
|
202
161
|
```
|
|
203
162
|
|
|
204
163
|
### Errors
|
|
@@ -213,10 +172,10 @@ All parsing and validation errors raise `ArgumentError` with descriptive message
|
|
|
213
172
|
|
|
214
173
|
## Design Principles
|
|
215
174
|
|
|
216
|
-
- **Bounded values**: Explicit validation of
|
|
175
|
+
- **Bounded values**: Explicit validation of abbreviations and sides
|
|
217
176
|
- **Object-oriented**: `Identifier` class enables methods and encapsulation
|
|
218
177
|
- **Ruby idioms**: `valid?` predicate, `to_s` conversion, `ArgumentError` for invalid input
|
|
219
|
-
- **Immutable identifiers**:
|
|
178
|
+
- **Immutable identifiers**: Instances are frozen after creation
|
|
220
179
|
- **No dependencies**: Pure Ruby standard library only
|
|
221
180
|
|
|
222
181
|
## Related Specifications
|
|
@@ -4,20 +4,20 @@ module Sashite
|
|
|
4
4
|
module Sin
|
|
5
5
|
# Constants for the SIN (Style Identifier Notation) specification.
|
|
6
6
|
#
|
|
7
|
-
# Defines valid values for
|
|
7
|
+
# Defines valid values for abbreviations and sides, as well as formatting constants.
|
|
8
8
|
#
|
|
9
|
-
# @example Accessing valid
|
|
10
|
-
# Constants::
|
|
9
|
+
# @example Accessing valid abbreviations
|
|
10
|
+
# Constants::VALID_ABBRS # => [:A, :B, ..., :Z]
|
|
11
11
|
#
|
|
12
12
|
# @example Accessing valid sides
|
|
13
13
|
# Constants::VALID_SIDES # => [:first, :second]
|
|
14
14
|
#
|
|
15
15
|
# @see https://sashite.dev/specs/sin/1.0.0/
|
|
16
16
|
module Constants
|
|
17
|
-
# Valid
|
|
17
|
+
# Valid abbreviation symbols (A-Z as uppercase symbols).
|
|
18
18
|
#
|
|
19
|
-
# @return [Array<Symbol>] Array of 26 valid
|
|
20
|
-
|
|
19
|
+
# @return [Array<Symbol>] Array of 26 valid abbreviation symbols
|
|
20
|
+
VALID_ABBRS = %i[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z].freeze
|
|
21
21
|
|
|
22
22
|
# Valid side symbols.
|
|
23
23
|
#
|
|
@@ -29,10 +29,10 @@ module Sashite
|
|
|
29
29
|
# @return [String] Error message
|
|
30
30
|
MUST_BE_LETTER = "must be a letter"
|
|
31
31
|
|
|
32
|
-
# Error message for invalid
|
|
32
|
+
# Error message for invalid abbreviation value.
|
|
33
33
|
#
|
|
34
34
|
# @return [String] Error message
|
|
35
|
-
|
|
35
|
+
INVALID_ABBR = "invalid abbr"
|
|
36
36
|
|
|
37
37
|
# Error message for invalid side value.
|
|
38
38
|
#
|
|
@@ -8,7 +8,7 @@ module Sashite
|
|
|
8
8
|
# Represents a parsed SIN (Style Identifier Notation) identifier.
|
|
9
9
|
#
|
|
10
10
|
# An Identifier encodes two attributes:
|
|
11
|
-
# -
|
|
11
|
+
# - Abbr: the style abbreviation (A-Z as uppercase symbol)
|
|
12
12
|
# - Side: the player side (:first or :second)
|
|
13
13
|
#
|
|
14
14
|
# Instances are immutable (frozen after creation).
|
|
@@ -23,21 +23,21 @@ module Sashite
|
|
|
23
23
|
#
|
|
24
24
|
# @see https://sashite.dev/specs/sin/1.0.0/
|
|
25
25
|
class Identifier
|
|
26
|
-
# Valid
|
|
27
|
-
|
|
26
|
+
# Valid abbreviation symbols (A-Z).
|
|
27
|
+
VALID_ABBRS = Constants::VALID_ABBRS
|
|
28
28
|
|
|
29
29
|
# Valid side symbols.
|
|
30
30
|
VALID_SIDES = Constants::VALID_SIDES
|
|
31
31
|
|
|
32
|
-
# @return [Symbol]
|
|
33
|
-
attr_reader :
|
|
32
|
+
# @return [Symbol] Style abbreviation (:A to :Z, always uppercase)
|
|
33
|
+
attr_reader :abbr
|
|
34
34
|
|
|
35
35
|
# @return [Symbol] Player side (:first or :second)
|
|
36
36
|
attr_reader :side
|
|
37
37
|
|
|
38
38
|
# Creates a new Identifier instance.
|
|
39
39
|
#
|
|
40
|
-
# @param
|
|
40
|
+
# @param abbr [Symbol] Style abbreviation (:A to :Z)
|
|
41
41
|
# @param side [Symbol] Player side (:first or :second)
|
|
42
42
|
# @return [Identifier] A new frozen Identifier instance
|
|
43
43
|
# @raise [Errors::Argument] If any attribute is invalid
|
|
@@ -45,11 +45,11 @@ module Sashite
|
|
|
45
45
|
# @example
|
|
46
46
|
# Identifier.new(:C, :first)
|
|
47
47
|
# Identifier.new(:S, :second)
|
|
48
|
-
def initialize(
|
|
49
|
-
|
|
48
|
+
def initialize(abbr, side)
|
|
49
|
+
validate_abbr!(abbr)
|
|
50
50
|
validate_side!(side)
|
|
51
51
|
|
|
52
|
-
@
|
|
52
|
+
@abbr = abbr
|
|
53
53
|
@side = side
|
|
54
54
|
|
|
55
55
|
freeze
|
|
@@ -67,18 +67,7 @@ module Sashite
|
|
|
67
67
|
# Identifier.new(:C, :first).to_s # => "C"
|
|
68
68
|
# Identifier.new(:C, :second).to_s # => "c"
|
|
69
69
|
def to_s
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Returns the letter component of the SIN.
|
|
74
|
-
#
|
|
75
|
-
# @return [String] Uppercase for first player, lowercase for second
|
|
76
|
-
#
|
|
77
|
-
# @example
|
|
78
|
-
# Identifier.new(:C, :first).letter # => "C"
|
|
79
|
-
# Identifier.new(:C, :second).letter # => "c"
|
|
80
|
-
def letter
|
|
81
|
-
base = String(style)
|
|
70
|
+
base = String(abbr)
|
|
82
71
|
|
|
83
72
|
case side
|
|
84
73
|
when :first then base.upcase
|
|
@@ -86,56 +75,6 @@ module Sashite
|
|
|
86
75
|
end
|
|
87
76
|
end
|
|
88
77
|
|
|
89
|
-
# ========================================================================
|
|
90
|
-
# Side Transformations
|
|
91
|
-
# ========================================================================
|
|
92
|
-
|
|
93
|
-
# Returns a new Identifier with the opposite side.
|
|
94
|
-
#
|
|
95
|
-
# @return [Identifier] A new Identifier with flipped side
|
|
96
|
-
#
|
|
97
|
-
# @example
|
|
98
|
-
# sin = Identifier.new(:C, :first)
|
|
99
|
-
# sin.flip.to_s # => "c"
|
|
100
|
-
def flip
|
|
101
|
-
new_side = first_player? ? :second : :first
|
|
102
|
-
self.class.new(style, new_side)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# ========================================================================
|
|
106
|
-
# Attribute Transformations
|
|
107
|
-
# ========================================================================
|
|
108
|
-
|
|
109
|
-
# Returns a new Identifier with a different style.
|
|
110
|
-
#
|
|
111
|
-
# @param new_style [Symbol] The new piece style (:A to :Z)
|
|
112
|
-
# @return [Identifier] A new Identifier with the specified style
|
|
113
|
-
# @raise [Errors::Argument] If the style is invalid
|
|
114
|
-
#
|
|
115
|
-
# @example
|
|
116
|
-
# sin = Identifier.new(:C, :first)
|
|
117
|
-
# sin.with_style(:S).to_s # => "S"
|
|
118
|
-
def with_style(new_style)
|
|
119
|
-
return self if style.equal?(new_style)
|
|
120
|
-
|
|
121
|
-
self.class.new(new_style, side)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Returns a new Identifier with a different side.
|
|
125
|
-
#
|
|
126
|
-
# @param new_side [Symbol] The new side (:first or :second)
|
|
127
|
-
# @return [Identifier] A new Identifier with the specified side
|
|
128
|
-
# @raise [Errors::Argument] If the side is invalid
|
|
129
|
-
#
|
|
130
|
-
# @example
|
|
131
|
-
# sin = Identifier.new(:C, :first)
|
|
132
|
-
# sin.with_side(:second).to_s # => "c"
|
|
133
|
-
def with_side(new_side)
|
|
134
|
-
return self if side.equal?(new_side)
|
|
135
|
-
|
|
136
|
-
self.class.new(style, new_side)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
78
|
# ========================================================================
|
|
140
79
|
# Side Queries
|
|
141
80
|
# ========================================================================
|
|
@@ -164,17 +103,17 @@ module Sashite
|
|
|
164
103
|
# Comparison Queries
|
|
165
104
|
# ========================================================================
|
|
166
105
|
|
|
167
|
-
# Checks if two Identifiers have the same
|
|
106
|
+
# Checks if two Identifiers have the same abbreviation.
|
|
168
107
|
#
|
|
169
108
|
# @param other [Identifier] The other Identifier to compare
|
|
170
|
-
# @return [Boolean] true if same
|
|
109
|
+
# @return [Boolean] true if same abbreviation
|
|
171
110
|
#
|
|
172
111
|
# @example
|
|
173
112
|
# sin1 = Identifier.new(:C, :first)
|
|
174
113
|
# sin2 = Identifier.new(:C, :second)
|
|
175
|
-
# sin1.
|
|
176
|
-
def
|
|
177
|
-
|
|
114
|
+
# sin1.same_abbr?(sin2) # => true
|
|
115
|
+
def same_abbr?(other)
|
|
116
|
+
abbr.equal?(other.abbr)
|
|
178
117
|
end
|
|
179
118
|
|
|
180
119
|
# Checks if two Identifiers have the same side.
|
|
@@ -206,7 +145,7 @@ module Sashite
|
|
|
206
145
|
def ==(other)
|
|
207
146
|
return false unless self.class === other
|
|
208
147
|
|
|
209
|
-
|
|
148
|
+
abbr.equal?(other.abbr) && side.equal?(other.side)
|
|
210
149
|
end
|
|
211
150
|
|
|
212
151
|
alias eql? ==
|
|
@@ -215,7 +154,7 @@ module Sashite
|
|
|
215
154
|
#
|
|
216
155
|
# @return [Integer] Hash code
|
|
217
156
|
def hash
|
|
218
|
-
[
|
|
157
|
+
[abbr, side].hash
|
|
219
158
|
end
|
|
220
159
|
|
|
221
160
|
# Returns an inspect string for the Identifier.
|
|
@@ -234,10 +173,10 @@ module Sashite
|
|
|
234
173
|
# Private Validation
|
|
235
174
|
# ========================================================================
|
|
236
175
|
|
|
237
|
-
def
|
|
238
|
-
return if ::Symbol ===
|
|
176
|
+
def validate_abbr!(abbr)
|
|
177
|
+
return if ::Symbol === abbr && Constants::VALID_ABBRS.include?(abbr)
|
|
239
178
|
|
|
240
|
-
raise Errors::Argument, Errors::Argument::Messages::
|
|
179
|
+
raise Errors::Argument, Errors::Argument::Messages::INVALID_ABBR
|
|
241
180
|
end
|
|
242
181
|
|
|
243
182
|
def validate_side!(side)
|
data/lib/sashite/sin/parser.rb
CHANGED
|
@@ -11,8 +11,8 @@ module Sashite
|
|
|
11
11
|
# malformed input, Unicode lookalikes, and injection attacks.
|
|
12
12
|
#
|
|
13
13
|
# @example Parsing a valid SIN string
|
|
14
|
-
# Parser.parse("C") # => {
|
|
15
|
-
# Parser.parse("c") # => {
|
|
14
|
+
# Parser.parse("C") # => { abbr: :C, side: :first }
|
|
15
|
+
# Parser.parse("c") # => { abbr: :C, side: :second }
|
|
16
16
|
#
|
|
17
17
|
# @example Validation
|
|
18
18
|
# Parser.valid?("C") # => true
|
|
@@ -23,12 +23,12 @@ module Sashite
|
|
|
23
23
|
# Parses a SIN string into its components.
|
|
24
24
|
#
|
|
25
25
|
# @param input [String] The SIN string to parse
|
|
26
|
-
# @return [Hash] Hash with :
|
|
26
|
+
# @return [Hash] Hash with :abbr and :side keys
|
|
27
27
|
# @raise [Errors::Argument] If the input is invalid
|
|
28
28
|
#
|
|
29
29
|
# @example
|
|
30
|
-
# Parser.parse("C") # => {
|
|
31
|
-
# Parser.parse("s") # => {
|
|
30
|
+
# Parser.parse("C") # => { abbr: :C, side: :first }
|
|
31
|
+
# Parser.parse("s") # => { abbr: :S, side: :second }
|
|
32
32
|
def self.parse(input)
|
|
33
33
|
validate_input_type!(input)
|
|
34
34
|
validate_not_empty!(input)
|
|
@@ -103,15 +103,15 @@ module Sashite
|
|
|
103
103
|
raise Errors::Argument, Errors::Argument::Messages::MUST_BE_LETTER
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
# Extracts
|
|
106
|
+
# Extracts abbr and side from a validated byte.
|
|
107
107
|
#
|
|
108
108
|
# @param byte [Integer] A validated ASCII letter byte
|
|
109
|
-
# @return [Hash] Hash with :
|
|
109
|
+
# @return [Hash] Hash with :abbr and :side keys
|
|
110
110
|
private_class_method def self.extract_components(byte)
|
|
111
111
|
if uppercase_letter?(byte)
|
|
112
|
-
{
|
|
112
|
+
{ abbr: byte.chr.to_sym, side: :first }
|
|
113
113
|
else
|
|
114
|
-
{
|
|
114
|
+
{ abbr: byte.chr.upcase.to_sym, side: :second }
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
data/lib/sashite/sin.rb
CHANGED
|
@@ -17,9 +17,9 @@ module Sashite
|
|
|
17
17
|
#
|
|
18
18
|
# @example Parsing SIN strings
|
|
19
19
|
# sin = Sashite::Sin.parse("C")
|
|
20
|
-
# sin.
|
|
21
|
-
# sin.side
|
|
22
|
-
# sin.to_s
|
|
20
|
+
# sin.abbr # => :C
|
|
21
|
+
# sin.side # => :first
|
|
22
|
+
# sin.to_s # => "C"
|
|
23
23
|
#
|
|
24
24
|
# @example Creating identifiers directly
|
|
25
25
|
# sin = Sashite::Sin::Identifier.new(:C, :first)
|
|
@@ -39,17 +39,17 @@ module Sashite
|
|
|
39
39
|
#
|
|
40
40
|
# @example Parsing uppercase (first player)
|
|
41
41
|
# sin = Sashite::Sin.parse("C")
|
|
42
|
-
# sin.
|
|
43
|
-
# sin.side
|
|
42
|
+
# sin.abbr # => :C
|
|
43
|
+
# sin.side # => :first
|
|
44
44
|
#
|
|
45
45
|
# @example Parsing lowercase (second player)
|
|
46
46
|
# sin = Sashite::Sin.parse("c")
|
|
47
|
-
# sin.
|
|
48
|
-
# sin.side
|
|
47
|
+
# sin.abbr # => :C
|
|
48
|
+
# sin.side # => :second
|
|
49
49
|
def self.parse(input)
|
|
50
50
|
components = Parser.parse(input)
|
|
51
51
|
|
|
52
|
-
Identifier.new(components.fetch(:
|
|
52
|
+
Identifier.new(components.fetch(:abbr), components.fetch(:side))
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
# Reports whether the input is a valid SIN string.
|
data/lib/sashite-sin.rb
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "sashite/sin"
|
|
4
|
-
|
|
5
|
-
# Sashité namespace for board game notation libraries
|
|
6
|
-
#
|
|
7
|
-
# Sashité provides a collection of libraries for representing and manipulating
|
|
8
|
-
# board game concepts according to the Sashité Protocol specifications.
|
|
9
|
-
#
|
|
10
|
-
# @see https://sashite.dev/protocol/ Sashité Protocol
|
|
11
|
-
# @see https://sashite.dev/specs/ Sashité Specifications
|
|
12
|
-
# @author Sashité
|
|
13
|
-
module Sashite
|
|
14
|
-
end
|