yzz 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yzz.rb +20 -1
- data/lib/yzz/version.rb +1 -1
- data/test/yzz_test.rb +22 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80b401ab66ecd06b2fc106da76528f08b9d0701f
|
4
|
+
data.tar.gz: 3fcc4b09af7214149509b95cd939b234d3790d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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:
|
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-
|
11
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|