yzz 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86214ab87ff3d7b69aa7dbc97c29abcd49b54d13
4
- data.tar.gz: 25f05cecae9791711642b5ca7a8e57db6ffad447
3
+ metadata.gz: 80b401ab66ecd06b2fc106da76528f08b9d0701f
4
+ data.tar.gz: 3fcc4b09af7214149509b95cd939b234d3790d3f
5
5
  SHA512:
6
- metadata.gz: 4eb9074c30c908c2ede65fe40498f680af6780a339f5cae54b2b8d1c83dddba82f242f490b6d93abea4c5e10ca7a0131b222c13836b2ed6857f4320362be4212
7
- data.tar.gz: 2c9138c9a46f60259f3bbc443f27c593f51d4a535eb7e77f608f971906e8a90f8a618f9da656e8a0148c22d7b6031221fd1142c61d28fb824d714885a2b24971
6
+ metadata.gz: 4d2ea45b49f2db08815b11e6c14fc00bc45bf269f3c4a6ce741c43fae368201646bf6d75aaaf8c6f610882ad95d291e9372dd8174aa66ced31078eb4ed6ba944
7
+ data.tar.gz: 4f8d6a6ad33814b2485a0e9cffb4a3a4219b9bea61d70547822de15d2021cb847b3310e7747aa416da75adaf7a5c9ec001fa0f0b61e829f1ece1ba6c0262f546
data/lib/yzz.rb CHANGED
@@ -43,7 +43,26 @@ module Yzz
43
43
  def along dimension
44
44
  @zz_dimensions[ dimension ]
45
45
  end
46
- alias call along
46
+
47
+ # Returns all sides actually connected to a zz object.
48
+ #
49
+ def connections
50
+ @zz_dimensions.map { |_, pair| [ pair.negward, pair.posward ] }
51
+ .reduce( [], :+ ).select { |side| side.neighbor.is_a_zz? }
52
+ end
53
+ alias connectivity connections
54
+
55
+ # Returns all neighbors of a zz object.
56
+ #
57
+ def neighbors; connections.map &:neighbor end
58
+
59
+ # Returns all sides facing another zz object supplied as argument. (Note that
60
+ # this can be <em>more than 1</em> side: object A can be connected to B along
61
+ # more than 1 dimension.
62
+ #
63
+ def towards other
64
+ connectivity.select { |side| side.neighbor == other }
65
+ end
47
66
  end
48
67
 
49
68
  class Object
data/lib/yzz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yzz
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/test/yzz_test.rb CHANGED
@@ -27,7 +27,6 @@ describe Yzz do
27
27
  it "provides #along instance method" do
28
28
  zz = @ç.new
29
29
  assert_kind_of Yzz::SidePair, zz.along( :row )
30
- assert_equal zz.along( :row ), zz.(:row)
31
30
  end
32
31
 
33
32
  describe 'basic zz object behavior' do
@@ -36,42 +35,40 @@ describe Yzz do
36
35
  end
37
36
 
38
37
  it "provides two sides, #opposite_side also tested" do
39
- assert_equal @a.(:row).posward, @a.(:row).n.opposite_side
40
- assert_equal @a.(:row).negward, @a.(:row).p.opposite_side
38
+ assert_equal @a.along(:row).posward, @a.along(:row).n.opposite_side
39
+ assert_equal @a.along(:row).negward, @a.along(:row).p.opposite_side
41
40
  end
42
41
 
43
42
  it "has #to_s" do
44
- assert @a.(:row).to_s.starts_with? "#<YTed::Zz::SidePair"
43
+ assert @a.along(:row).to_s.starts_with? "#<YTed::Zz::SidePair"
45
44
  end
46
45
 
47
46
  describe 'more advanced zz object behavior' do
48
47
  it "has #same_side" do
49
48
  zz = @ç.new
50
- assert_equal zz.(:row).p, @a.(:row).p.same_side( of: zz )
51
- assert_equal zz.(:row).n, @a.(:row).n.same_side( of: zz )
49
+ assert_equal zz.along(:row).p, @a.along(:row).p.same_side( of: zz )
50
+ assert_equal zz.along(:row).n, @a.along(:row).n.same_side( of: zz )
52
51
  end
53
52
 
54
53
  it "works" do
55
54
  a, b, c = @ç.new, @ç.new, @ç.new
56
- assert ( b.(:row).posward << c ).nil?
57
- assert_equal c, b.(:row).P
58
- assert_equal b, c.(:row).N
59
- assert ( b.(:row).negward << a ).nil?
60
- assert_equal a, b.(:row).N
61
- assert_equal b, a.(:row).P
62
- assert_equal b, c.(:row).negward.unlink
63
- assert_equal b, a.(:row).posward.unlink
64
- a.(:row) >> b >> c
65
- assert_equal b, a.(:row).posward * c
66
- assert_equal b, b.(:row) * c
67
- assert_equal b, a.(:row).P
68
- assert_equal c, b.(:row).P
69
- # TODO:
70
- # assert_equal [a, c], b.connections.map { |side| side.neighbor }
71
- # assert_equal [a, c], b.neighbors
72
- # assert_equal [ b.(:row).negward ], b.connections( to: a )
73
- # assert_equal [ b.(:row).posward ], b.connections( to: c )
74
- # TODO: Rename YTed to Zz
55
+ assert ( b.along(:row).posward << c ).nil?
56
+ assert_equal c, b.along(:row).P
57
+ assert_equal b, c.along(:row).N
58
+ assert ( b.along(:row).negward << a ).nil?
59
+ assert_equal a, b.along(:row).N
60
+ assert_equal b, a.along(:row).P
61
+ assert_equal b, c.along(:row).negward.unlink
62
+ assert_equal b, a.along(:row).posward.unlink
63
+ a.along(:row) >> b >> c
64
+ assert_equal b, a.along(:row).posward * c
65
+ assert_equal b, b.along(:row) * c
66
+ assert_equal b, a.along(:row).P
67
+ assert_equal c, b.along(:row).P
68
+ assert_equal [a, c], b.connections.map { |side| side.neighbor }
69
+ assert_equal [a, c], b.neighbors
70
+ assert_equal [ b.along(:row).negward ], b.towards( a )
71
+ assert_equal [ b.along(:row).posward ], b.towards( c )
75
72
  end
76
73
  end
77
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-28 00:00:00.000000000 Z
11
+ date: 2013-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler