feen 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/feen/dumper/in_hand.rb +9 -5
- data/lib/feen/parser/in_hand.rb +6 -0
- 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: 1a033acfb60b8db7f259e6e787c71c6e9cae62ef3127faeddfec5c881e9a0171
|
4
|
+
data.tar.gz: f62cf07a12178a848df661c9a695bc7eb9c8adcac1ea399c252f7c4d9aee77af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96c233e0adb0998281b40e8b282526275ace24c53d9200fffd66907617b0b905d34c592ad7f45659d3f8df9dfa64e738c825c2582b6e5d18da443008a2ae348
|
7
|
+
data.tar.gz: 443ec302a41d65bc96ca9605edc8d3b2f8fbfd323d042da95a3d783c86f7af301389d8d61f9e1114ec019084d94afe1af8602a70e9b4511ce6a8df177e8f6b82
|
data/lib/feen/dumper/in_hand.rb
CHANGED
@@ -2,16 +2,20 @@
|
|
2
2
|
|
3
3
|
module FEEN
|
4
4
|
module Dumper
|
5
|
-
# The pieces in hand
|
6
|
-
#
|
7
|
-
# @example Serialize a list of pieces in hand grouped by sides
|
8
|
-
# PiecesInHand.dump(%w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p])
|
9
|
-
# # => "S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
5
|
+
# The pieces in hand module.
|
10
6
|
module InHand
|
11
7
|
# Serialize pieces in hand lists into a string.
|
12
8
|
#
|
13
9
|
# @param piece_names [Array] A list of pieces in hand.
|
14
10
|
#
|
11
|
+
# @example Dump a list of pieces in hand
|
12
|
+
# dump(["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"])
|
13
|
+
# # => "S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
14
|
+
#
|
15
|
+
# @example Dump an empty list of pieces in hand
|
16
|
+
# dump([])
|
17
|
+
# # => "-"
|
18
|
+
#
|
15
19
|
# @return [String] A string representing the pieces in hand.
|
16
20
|
def self.dump(piece_names)
|
17
21
|
return "-" if piece_names.empty?
|
data/lib/feen/parser/in_hand.rb
CHANGED
@@ -12,8 +12,14 @@ module FEEN
|
|
12
12
|
# parse("S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
13
13
|
# # => ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"]
|
14
14
|
#
|
15
|
+
# @example Parse an empty list of serialized pieces in hand
|
16
|
+
# parse("-")
|
17
|
+
# # => []
|
18
|
+
#
|
15
19
|
# @return [Array] The list of pieces in hand grouped by players.
|
16
20
|
def self.parse(piece_names_str)
|
21
|
+
return [] if piece_names_str == "-"
|
22
|
+
|
17
23
|
piece_names_str.split(",")
|
18
24
|
end
|
19
25
|
end
|