board_game_grid 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/board_game_grid/square_set.rb +28 -1
- data/lib/board_game_grid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbcdb4a9672a1d039ef09cccc368dcaaf01463258683bc3dc80f557e018918f2
|
4
|
+
data.tar.gz: 0d8cf28d4594433989f48ab193e1db4feb74aa971ec254f123db6d500c8b5046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7cc7f9587922d5fd23760df797cf5f83aef6f0ad57836b642287b16d9aa446980c6030e1e776496eed0cb12b27a7f56aac18a252ddf2153f0d6c38153b81999
|
7
|
+
data.tar.gz: ad708fd41faa49f3cc5f090e5d6396efbd33dab9a8ddcfa5cc2cf86f81309293ef0224ede0e788bed7af7dc4f0bfbfd2edaa8d7d0854945f7a508f2a8bd082eb
|
@@ -102,7 +102,24 @@ module BoardGameGrid
|
|
102
102
|
# # Find the intersection of Squares
|
103
103
|
# square_set & other
|
104
104
|
def &(other)
|
105
|
-
|
105
|
+
_squares = self.squares & other.squares
|
106
|
+
|
107
|
+
self.class.new(squares: _squares)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Find the union of Squares between sets
|
111
|
+
#
|
112
|
+
# @param [SquareSet] other
|
113
|
+
# the second SquareSet
|
114
|
+
#
|
115
|
+
# @return [SquareSet]
|
116
|
+
# ==== Example:
|
117
|
+
# # Find the union of Squares
|
118
|
+
# square_set | other
|
119
|
+
def |(other)
|
120
|
+
_squares = self.squares | other.squares
|
121
|
+
|
122
|
+
self.class.new(squares: _squares)
|
106
123
|
end
|
107
124
|
|
108
125
|
# Filter the squares with a block and behaves like Enumerable#select.
|
@@ -115,6 +132,16 @@ module BoardGameGrid
|
|
115
132
|
self.class.new(squares: _squares)
|
116
133
|
end
|
117
134
|
|
135
|
+
# Get unique elements in the set. Behaves like Enumerable#uniq.
|
136
|
+
# It returns a SquareSet with the unique squares.
|
137
|
+
#
|
138
|
+
# @return [SquareSet]
|
139
|
+
def uniq
|
140
|
+
_squares = squares.uniq
|
141
|
+
|
142
|
+
self.class.new(squares: _squares)
|
143
|
+
end
|
144
|
+
|
118
145
|
# Filter the squares with a hash of attribute and matching values.
|
119
146
|
#
|
120
147
|
# @param [Hash] hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: board_game_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Humphreys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|