Class: Yzz::SidePair
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
-
#negward ⇒ Object
(also: #n)
readonly
Returns the value of attribute negward.
-
#posward ⇒ Object
(also: #p)
readonly
Returns the value of attribute posward.
Instance Method Summary collapse
-
#*(new_neighbor) ⇒ Object
Crossovers the supplied zz object posward.
-
#>>(new_neighbor) ⇒ Object
Makes the supplied object the posward neighbor of the receiver.
-
#dimension ⇒ Object
Reader #dimension delegates to the class, relying on parametrized subclassing.
-
#initialize(negward_neighbor: nil, posward_neighbor: nil) ⇒ SidePair
constructor
Takes two optional named parameters, :negward_neighbor and :posward_neigbor.
-
#inspect ⇒ Object
Instance inspect string.
-
#N ⇒ Object
Returns negward neighbor.
-
#P ⇒ Object
Returns posward neighbor.
-
#to_s ⇒ Object
Returns the string briefly describing the instance.
-
#zz ⇒ Object
Reader #zz delegates to the class, relying on parametrized subclassing.
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
#negward ⇒ Object (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 |
#posward ⇒ Object (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 |
#dimension ⇒ Object
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 |
#inspect ⇒ Object
Instance inspect string.
61 62 63 |
# File 'lib/yzz/side_pair.rb', line 61 def inspect to_s end |
#N ⇒ Object
Returns negward neighbor.
51 |
# File 'lib/yzz/side_pair.rb', line 51 def N; negward.neighbor end |
#P ⇒ Object
Returns posward neighbor.
47 |
# File 'lib/yzz/side_pair.rb', line 47 def P; posward.neighbor end |
#to_s ⇒ Object
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 |
#zz ⇒ Object
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 |