portable_move_notation 2.0.0 → 2.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/README.md +2 -2
- data/lib/portable_move_notation/action.rb +7 -1
- 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: bae8f26119505e33c79cbf389b10c8f737a60aca132e4c39b7f1b0dcd820e2c9
|
4
|
+
data.tar.gz: 735910e4fa03d366cb8d7a63889637a3e3bc4d360e168a2fbe85d28416ae33cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d8644574aad3f7b1224198cc8505aad36c35380bafe257640add785baa273237616187f6c93fa9db0433edc6436483106be7396fa68f33921ca4264f3bfdb1
|
7
|
+
data.tar.gz: 1271f9c59dcff69bdf8a305b4f03daa4cc71982d5e92db7fd28fac6e2ee8d3663b9a63d989db076a7c14d7c544b9b92c212d0ca3b4624ba86c203fe64db5d08f
|
data/README.md
CHANGED
@@ -226,7 +226,7 @@ After white plays a double pawn move from e2 (52) to e4 (36), black captures en
|
|
226
226
|
initial_move = PortableMoveNotation::Action.new(
|
227
227
|
src_square: 52,
|
228
228
|
dst_square: 36,
|
229
|
-
piece_name: "P",
|
229
|
+
piece_name: "P'",
|
230
230
|
piece_hand: nil
|
231
231
|
)
|
232
232
|
|
@@ -242,7 +242,7 @@ capture_action2 = PortableMoveNotation::Action.new(
|
|
242
242
|
src_square: 36,
|
243
243
|
dst_square: 44,
|
244
244
|
piece_name: "p",
|
245
|
-
piece_hand:
|
245
|
+
piece_hand: nil
|
246
246
|
)
|
247
247
|
|
248
248
|
en_passant_move = PortableMoveNotation::Move.new(capture_action1, capture_action2)
|
@@ -24,6 +24,12 @@ module PortableMoveNotation
|
|
24
24
|
# @see https://sashite.dev/documents/pmn/1.0.0/ PMN Specification
|
25
25
|
# @see https://sashite.dev/documents/pnn/1.0.0/ PNN Specification for piece format
|
26
26
|
class Action
|
27
|
+
# Regular expression pattern for validating PNN piece names
|
28
|
+
# Format: [prefix]letter[suffix]
|
29
|
+
# - prefix: optional '+' or '-'
|
30
|
+
# - letter: required 'a-z' or 'A-Z'
|
31
|
+
# - suffix: optional "'"
|
32
|
+
PIECE_NAME_PATTERN = /\A[-+]?[a-zA-Z][']?\z/
|
27
33
|
# Validates a PMN action hash
|
28
34
|
#
|
29
35
|
# @param action_data [Hash] PMN action data to validate
|
@@ -141,7 +147,7 @@ module PortableMoveNotation
|
|
141
147
|
# @param piece_name [Object] Piece name to validate
|
142
148
|
# @raise [ArgumentError] if the format is invalid
|
143
149
|
def validate_piece_name(piece_name)
|
144
|
-
return if piece_name.is_a?(::String) && piece_name.match?(
|
150
|
+
return if piece_name.is_a?(::String) && piece_name.match?(PIECE_NAME_PATTERN)
|
145
151
|
|
146
152
|
raise ::ArgumentError, "Invalid piece_name format: #{piece_name}"
|
147
153
|
end
|