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(zz: ( raise ArgumentError, ":zz missing!" ), dimension: ( raise ArgumentError, ":dimension missing!" ), negward_neighbor: nil, posward_neighbor: nil) ⇒ SidePair

Returns a new instance of SidePair.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/yzz/side_pair.rb', line 9

def initialize( zz: ( raise ArgumentError, ":zz missing!" ),
                dimension: ( raise ArgumentError, ":dimension missing!" ),
                negward_neighbor: nil,
                posward_neighbor: nil )
  @zz, @dimension = zz, dimension
  @negward = Yzz::Side.new( zz: zz,
                            dimension: dimension,
                            direction: :negward,
                            neighbor: negward_neighbor )
  @posward = Yzz::Side.new( zz: zz,
                            dimension: dimension,
                            direction: :posward,
                            neighbor: posward_neighbor )
end

Instance Attribute Details

#dimensionObject (readonly)

Returns the value of attribute dimension.



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

def dimension
  @dimension
end

#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

#zzObject (readonly)

Returns the value of attribute zz.



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

def zz
  @zz
end

Instance Method Details

#*(new_neighbor) ⇒ Object

Crossovers a new neighbor posward.



32
33
34
# File 'lib/yzz/side_pair.rb', line 32

def * new_neighbor
  posward * new_neighbor
end

#>>(new_neighbor) ⇒ Object

Links a neighbor posward.



26
27
28
# File 'lib/yzz/side_pair.rb', line 26

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

#inspectObject

Instance inspect string.



52
53
54
# File 'lib/yzz/side_pair.rb', line 52

def inspect
  to_s
end

#NObject

Returns negward neighbor.



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

def N; negward.neighbor end

#PObject

Returns posward neighbor.



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

def P; posward.neighbor end

#to_sObject

Returns the string briefly describing the instance.



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

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