Class: Yzz::SidePair

Inherits:
Object show all
Defined in:
lib/yzz/side_pair.rb

Overview

This class represents a pair of a negward and posward side (Yzz::Side instance) of a Yzz cell along a certain dimension.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(negward_neighbor: nil, posward_neighbor: nil) ⇒ SidePair

Takes two optional named parameters, :negward_neighbor and :posward_neigbor. If not given, the sides are constructed not linked to any neigbors.



25
26
27
28
29
30
31
# File 'lib/yzz/side_pair.rb', line 25

def initialize( negward_neighbor: nil, posward_neighbor: nil )
  param_class!( { NegwardSide: ::Yzz::NegwardSide,
                  PoswardSide: ::Yzz::PoswardSide },
                with: { zz: zz, dimension: dimension } )
  @negward = NegwardSide().new( neighbor: negward_neighbor )
  @posward = PoswardSide().new( neighbor: posward_neighbor )
end

Instance Attribute Details

#negwardObject (readonly) Also known as: n

Returns the value of attribute negward.



5
6
7
# File 'lib/yzz/side_pair.rb', line 5

def negward
  @negward
end

#poswardObject (readonly) Also known as: p

Returns the value of attribute posward.



5
6
7
# File 'lib/yzz/side_pair.rb', line 5

def posward
  @posward
end

Instance Method Details

#*(new_neighbor) ⇒ Object

Crossovers the supplied zz object posward.



41
42
43
# File 'lib/yzz/side_pair.rb', line 41

def * new_neighbor
  posward * new_neighbor
end

#>>(new_neighbor) ⇒ Object

Makes the supplied object the posward neighbor of the receiver.



35
36
37
# File 'lib/yzz/side_pair.rb', line 35

def >> new_neighbor
  new_neighbor.along( dimension ).tap { posward << new_neighbor }
end

#dimensionObject

Reader #dimension delegates to the class, relying on parametrized subclassing.



18
19
20
# File 'lib/yzz/side_pair.rb', line 18

def dimension
  self.class.dimension
end

#inspectObject

Instance inspect string.



61
62
63
# File 'lib/yzz/side_pair.rb', line 61

def inspect
  to_s
end

#NObject

Returns negward neighbor.



51
# File 'lib/yzz/side_pair.rb', line 51

def N; negward.neighbor end

#PObject

Returns posward neighbor.



47
# File 'lib/yzz/side_pair.rb', line 47

def P; posward.neighbor end

#to_sObject

Returns the string briefly describing the instance.



55
56
57
# File 'lib/yzz/side_pair.rb', line 55

def to_s
  "#<Yzz::SidePair: #{zz} along #{dimension}>"
end

#zzObject

Reader #zz delegates to the class, relying on parametrized subclassing.



11
12
13
# File 'lib/yzz/side_pair.rb', line 11

def zz
  self.class.zz 
end