board_game_grid 0.1.1 → 0.1.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: e6f9e7dc165a1c2d598091bdca13ccd687c14ac9efe8b10bafe7cb88bf08295b
4
- data.tar.gz: 9f1a589630b15914883252d293a85a5b0e4d49962086561b839a2e4a3fef198a
3
+ metadata.gz: dbcdb4a9672a1d039ef09cccc368dcaaf01463258683bc3dc80f557e018918f2
4
+ data.tar.gz: 0d8cf28d4594433989f48ab193e1db4feb74aa971ec254f123db6d500c8b5046
5
5
  SHA512:
6
- metadata.gz: c3fe117a71a647924560cbe423f15ebfeb51b30a03a406dfb9bc0ec1be60e3a4712a9e00e8eea0259c6cec17e47fa2e76458c28719a1490374da02f809834150
7
- data.tar.gz: 8a632d630092bacff52b5143d1810ed87ea56bc2d992e6cc106f97160f9cf09416f9d5c6d93e05bfa2c5c53f23c156236fd5378acc6170a4efe5cbc98d9e6152
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
- select { |square| other.include?(square) }
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
@@ -1,3 +1,3 @@
1
1
  module BoardGameGrid
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-13 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler