sashite-pin 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0335d119541a7fa271689c6235a9c785a4c46f6c70e9577d4cddcc597d520dd5
4
- data.tar.gz: 7d95e04c803457156561bfe0fd8e270db5df1929b58721b9ed8266646f60e7e1
3
+ metadata.gz: 70bbc211cb1dd38efa9f0c39b2d0e1b0fd09c2dcf2d7ac3773719ce11786a5ac
4
+ data.tar.gz: cd6831f22ee3e9fd8ce559f5535bbcbb1d9ca13ba9083a9d9c1fe66d41e2eef9
5
5
  SHA512:
6
- metadata.gz: 6904c80bee041595400f4074ed48a975ad6337c3c5a8c66f9d18ad7864f19e23d04e34b30c725d37ce9c4bfde58667328a82bbd1c38208c123cb44a9da00b283
7
- data.tar.gz: 32289d6453d81ff2e1920aeb7d69eedfac6bc61f9acdd1929e7ca4bc09c6988bb2a64bc3620130cfb63024977e0508b7c5ffce695590382eac3420d85454c67a
6
+ metadata.gz: d0808aac8a46423256ec3546a4eb71d5882d3535b4a74929680cd31f84294ffd406716565f53ef072ff35c5c1131bb2612ab93398001d3d80772bb34a3dc3d07
7
+ data.tar.gz: ba7ecb1765c03c801f014bdbb9792fcae5dacd8d119890b0c73f0e550a345a8fc307cb39a82b803c986ef7fa50f76ad5fff39c6a7bffc5fe39e1b06bebe6b809
data/README.md CHANGED
@@ -204,6 +204,7 @@ crossed_soldier.to_s # => "+P"
204
204
  #### Creation and Parsing
205
205
  - `Sashite::Pin::Piece.new(type, side, state = :normal)` - Create piece instance
206
206
  - `Sashite::Pin::Piece.parse(pin_string)` - Parse PIN string (same as module method)
207
+ - `Sashite::Pin::Piece.valid?(pin_string)` - Validate PIN string (class method)
207
208
 
208
209
  #### Attribute Access
209
210
  - `#type` - Get piece type (symbol :A to :Z, always uppercase)
@@ -258,7 +259,7 @@ piece2.letter # => "k" (lowercase display)
258
259
  - `#==(other)` - Full equality comparison
259
260
 
260
261
  ### Constants
261
- - `Sashite::Pin::PIN_REGEX` - Regular expression for PIN validation
262
+ - `Sashite::Pin::Piece::PIN_PATTERN` - Regular expression for PIN validation (internal use)
262
263
 
263
264
  ## Advanced Usage
264
265
 
@@ -106,6 +106,23 @@ module Sashite
106
106
  new(piece_type, piece_side, piece_state)
107
107
  end
108
108
 
109
+ # Check if a string is a valid PIN notation
110
+ #
111
+ # @param pin_string [String] The string to validate
112
+ # @return [Boolean] true if valid PIN, false otherwise
113
+ #
114
+ # @example
115
+ # Sashite::Pin::Piece.valid?("K") # => true
116
+ # Sashite::Pin::Piece.valid?("+R") # => true
117
+ # Sashite::Pin::Piece.valid?("-p") # => true
118
+ # Sashite::Pin::Piece.valid?("KK") # => false
119
+ # Sashite::Pin::Piece.valid?("++K") # => false
120
+ def self.valid?(pin_string)
121
+ return false unless pin_string.is_a?(::String)
122
+
123
+ pin_string.match?(PIN_PATTERN)
124
+ end
125
+
109
126
  # Convert the piece to its PIN string representation
110
127
  #
111
128
  # @return [String] PIN notation string
@@ -190,9 +207,9 @@ module Sashite
190
207
  self.class.new(type, side, NORMAL_STATE)
191
208
  end
192
209
 
193
- # Create a new piece with opposite ownership (case)
210
+ # Create a new piece with opposite side
194
211
  #
195
- # @return [Piece] new piece instance with flipped case
212
+ # @return [Piece] new piece instance with opposite side
196
213
  # @example
197
214
  # piece.flip # (:K, :first, :normal) => (:K, :second, :normal)
198
215
  def flip
data/lib/sashite/pin.rb CHANGED
@@ -20,13 +20,9 @@ module Sashite
20
20
  #
21
21
  # See: https://sashite.dev/specs/pin/1.0.0/
22
22
  module Pin
23
- # Regular expression for PIN validation
24
- # Matches: optional state modifier followed by a single letter
25
- PIN_REGEX = /\A[-+]?[A-Za-z]\z/
26
-
27
23
  # Check if a string is a valid PIN notation
28
24
  #
29
- # @param pin [String] The string to validate
25
+ # @param pin_string [String] The string to validate
30
26
  # @return [Boolean] true if valid PIN, false otherwise
31
27
  #
32
28
  # @example
@@ -35,10 +31,8 @@ module Sashite
35
31
  # Sashite::Pin.valid?("-p") # => true
36
32
  # Sashite::Pin.valid?("KK") # => false
37
33
  # Sashite::Pin.valid?("++K") # => false
38
- def self.valid?(pin)
39
- return false unless pin.is_a?(::String)
40
-
41
- pin.match?(PIN_REGEX)
34
+ def self.valid?(pin_string)
35
+ Piece.valid?(pin_string)
42
36
  end
43
37
 
44
38
  # Parse a PIN string into a Piece object
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sashite-pin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato