board_game_grid 0.1.5 → 0.1.9

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: 10e78c90bda05726eb9b8b0d68f4526fa872279c063089eeb5ac0729411fadf2
4
- data.tar.gz: 832fb5ae71b1a0e6be4a56ff8b1e4cbcfd694315a8ed7c628cf47d4c1ba152eb
3
+ metadata.gz: a4a8a71192d04a29fc52392b43d2cf529345183506d75cba8cf2b48fa19a79e1
4
+ data.tar.gz: b1106c165058b32667a21168498c08026a3cdd39ecd6b2100df2dc20ec01c278
5
5
  SHA512:
6
- metadata.gz: 196ded6b6dbfa358570c041e9db00b7df582e59aaa92ab0cde8cd4121bac68db6a4eb2e9a13c72fe111f642c079b052742b185d441571913a78274980b8c95f2
7
- data.tar.gz: dee9e3fdcd61efb4c6b8b9fcf9f549b930b4c6da2ba3b1e202ac62689542e537a8200e21d5c9bf86f9f6ef5708371ce3d32f085b23321a7a554ad3d821535e37
6
+ metadata.gz: 2a9dc8424d4fdb0ab80ff86eb8441a8759375a042c48293d8fd03dc647aaf8a2de769feca7824f2800c239fa97d37145558676371af5022adfd9e5dfef978b2d
7
+ data.tar.gz: 01f681727b848101dde180858fff484a06890aa7134b79418d6d94e6a774a6b2d0f5e8f0e3235017473a6252f2b39348929c1d9e3e1dd3a565444a76bbb0b258
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.swp
@@ -5,4 +5,6 @@ module BoardGameGrid
5
5
 
6
6
  end
7
7
 
8
- require 'board_game_grid/square_set'
8
+ require 'board_game_grid/square_set'
9
+ require 'board_game_grid/square'
10
+ require 'board_game_grid/piece'
@@ -74,8 +74,12 @@ module BoardGameGrid
74
74
  def attribute_match?(attribute, value)
75
75
  hash_obj_matcher = lambda do |obj, k, v|
76
76
  value = obj.send(k)
77
- if !value.nil? && v.is_a?(Hash)
77
+ if v.is_a?(Hash) && !value.nil?
78
78
  v.all? { |k2,v2| hash_obj_matcher.call(value, k2, v2) }
79
+ elsif v.is_a?(Array) && !value.is_a?(Array)
80
+ v.include?(value)
81
+ elsif v.is_a?(Proc)
82
+ v.call(value)
79
83
  else
80
84
  value == v
81
85
  end
@@ -289,6 +289,32 @@ module BoardGameGrid
289
289
  select { |square| Vector.new(origin, square).dx.abs == distance }
290
290
  end
291
291
 
292
+ # Find all squares in the same rank as square
293
+ #
294
+ # @param [Square] square
295
+ # the originating square
296
+ #
297
+ # @return [SquareSet]
298
+ # ==== Example:
299
+ # # Get all squares in the same rank as square_a
300
+ # square_set.same_rank(square_a)
301
+ def same_rank(origin)
302
+ select { |square| square.y == origin.y }
303
+ end
304
+
305
+ # Find all squares in the same file as square
306
+ #
307
+ # @param [Square] square
308
+ # the originating square
309
+ #
310
+ # @return [SquareSet]
311
+ # ==== Example:
312
+ # # Get all squares in the same file as square_a
313
+ # square_set.same_file(square_a)
314
+ def same_file(origin)
315
+ select { |square| square.x == origin.x }
316
+ end
317
+
292
318
  # Find all squares orthogonal from square
293
319
  #
294
320
  # @param [Square] square
@@ -1,3 +1,3 @@
1
1
  module BoardGameGrid
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.9"
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.5
4
+ version: 0.1.9
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-04-23 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler