yzz 2.0.5 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9860ebc7b96fb69826c2141521128ab87f094de7
4
- data.tar.gz: 463614b5ee9ed02ae0af1c57d217cd0b28c7f714
3
+ metadata.gz: 71afce9e8205663f471fc06f91794c8431b427f0
4
+ data.tar.gz: bd85a78e18579012e0fca1fc9dd0226fd0fecb8f
5
5
  SHA512:
6
- metadata.gz: 10c94eaecf746f70f7714e782fac97beb752386a029c8da1cf7a7e69e16c92a8866319d01e562adaea8b0de1ab50d13d3dfda4ca89d72836cb1972d63ea53a2f
7
- data.tar.gz: 73f83d60ed2e57397bef44d8de8819e8de03d179222dfa4b3ad95541d0c1a77f8acfb011b0eabdb2a26e62774e3aec89013bf135f7a899a86b2f2e6f272118e6
6
+ metadata.gz: d1985109e51e93ab03df13eb2800900b4a2306466cbf5a65a0f0459b7b18b6c41e37b3843af073acaf030f782c5937b0f02f67cdd5d96e84e2e0121047baccb5
7
+ data.tar.gz: 7ec0dd897ac19354c8a19e11a99205661b9691cccfd8ae53fa92bc61e500058140b842578a858e1c1477d3e122007d83bd5ed45b7b9fb8878aa53dfa54679baf
data/README.md CHANGED
@@ -1,25 +1,65 @@
1
- # Yzz
1
+ # Yzz
2
2
 
3
- y_ted is a Zz structure domain model
3
+ `Yzz` is a domain model of Ted Nelson's Zz structures.
4
4
 
5
- ## Installation
5
+ ## Usage
6
6
 
7
- Add this line to your application's Gemfile:
7
+ The following usage example takes use of `y_support/name_magic` features.
8
+ Please install [y_support gem] before trying it.
9
+ ```ruby
10
+ require 'yzz'
11
+ require 'y_support/name_magic'
8
12
 
9
- gem 'yzz'
13
+ # Let's establish a new class and imbue it with Yzz quality.
14
+ #
15
+ class Cell
16
+ include Yzz, NameMagic
17
+ def to_s
18
+ name ? name.to_s : "#<Cell: #{connections.size} conn.>"
19
+ end
20
+ end
10
21
 
11
- And then execute:
22
+ # Let's create 6 new cells.
23
+ A1, A2, A3, B1, B2, B3 = 6.times.map { Cell.new }
12
24
 
13
- $ bundle
25
+ # And let's connect them along :x and :y dimensions:
26
+ A1.along( :x ) >> A2 >> A3
27
+ B1.along( :x ) >> B2 >> B3
28
+ A1.along( :y ) >> B1
29
+ A2.along( :y ) >> B2
30
+ A3.along( :y ) >> B3
14
31
 
15
- Or install it yourself as:
32
+ # The Zz structure that we have created looks like this:
33
+ #
34
+ # a1 --> a2 --> a3
35
+ # | | |
36
+ # | | |
37
+ # v v v
38
+ # b1 --> b2 --> b3
39
+ #
40
+ # The above structure is a little bit like a small spreadsheet 3×2.
16
41
 
17
- $ gem install yzz
42
+ # The structure can be investigated:
43
+ A1.neighbors # gives all the neighbors of A1
44
+ #=> [A2, B1]
45
+ A1.towards A2 # returns all the sides of A1 facing A2
46
+ #=> [#<Yzz::Side: A1 along x, posward>]
47
+ A1.tw A2 # more concise way of showing the sides facing A2
48
+ #=> x->
49
+ A1.tw B1
50
+ #=> y->
18
51
 
19
- ## Usage
52
+ # Of course, more complicated Zz structures can be created. See the [online
53
+ # presentation at xanadu.com for more](http://xanadu.com/zigzag/). For a small
54
+ # example here, let's create 2 diagonal connections:
20
55
 
21
- Zz structures have been described by Ted Nelson. Yzz provides mixin that
22
- imbues objects with zz structure qualities.
56
+ A1.along( :diagonal ) >> B2
57
+ A2.along( :diagonal ) >> B3
58
+ A1.tw B2
59
+ #=> diagonal->
60
+ A1.neighbors
61
+ #=> [A2, B1, B2]
62
+ ```
23
63
 
24
64
  ## Contributing
25
65
 
data/lib/yzz.rb CHANGED
@@ -67,6 +67,12 @@ module Yzz
67
67
  connectivity.select { |side| side.neighbor == other }
68
68
  end
69
69
 
70
+ # Prints the labels of the sides facing towards a given zz object.
71
+ #
72
+ def tw other
73
+ puts towards( other ).map &:label
74
+ end
75
+
70
76
  # Short string describing the object.
71
77
  #
72
78
  def to_s
data/lib/yzz/side.rb CHANGED
@@ -66,12 +66,6 @@ class Yzz::Side
66
66
  end
67
67
  alias * crossover
68
68
 
69
- # Returns the string briefly describing the instance.
70
- #
71
- def to_s
72
- "#<YTed::Zz::Side: #{direction} side of #{zz} along #{dimension}>"
73
- end
74
-
75
69
  # Given a zz object (named argument :of), returns its side along same
76
70
  # dimension, in the direction same as self.
77
71
  #
@@ -94,6 +88,24 @@ class Yzz::Side
94
88
  end
95
89
  end
96
90
 
91
+ # Returns the "side label" string.
92
+ #
93
+ def label
94
+ direction == :posward ? "#{dimension}->" : "<-#{dimension}"
95
+ end
96
+
97
+ # Returns the string briefly describing the instance.
98
+ #
99
+ def to_s
100
+ "#<Yzz::Side: #{zz} along #{dimension}, #{direction}>"
101
+ end
102
+
103
+ # Inspect string of the instance.
104
+ #
105
+ def inspect
106
+ to_s
107
+ end
108
+
97
109
  protected
98
110
 
99
111
  # Sets neighbor carelessly, returning the old neighbor.
data/lib/yzz/side_pair.rb CHANGED
@@ -44,6 +44,12 @@ class Yzz::SidePair
44
44
  # Returns the string briefly describing the instance.
45
45
  #
46
46
  def to_s
47
- "#<YTed::Zz::SidePair: #{zz} along dimension #{dimension} >"
47
+ "#<Yzz::SidePair: #{zz} along #{dimension}>"
48
+ end
49
+
50
+ # Instance inspect string.
51
+ #
52
+ def inspect
53
+ to_s
48
54
  end
49
55
  end # class YTed::Zz::SidePair
data/lib/yzz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yzz
2
- VERSION = "2.0.5"
2
+ VERSION = "2.0.7"
3
3
  end
data/test/yzz_test.rb CHANGED
@@ -40,7 +40,7 @@ describe Yzz do
40
40
  end
41
41
 
42
42
  it "has #to_s" do
43
- assert @a.along(:row).to_s.starts_with? "#<YTed::Zz::SidePair"
43
+ assert @a.along(:row).to_s.starts_with? "#<Yzz::SidePair"
44
44
  end
45
45
 
46
46
  describe 'more advanced zz object behavior' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris