Class: Nockr::Cell
Instance Attribute Summary collapse
-
#h ⇒ Object
readonly
Returns the value of attribute h.
-
#t ⇒ Object
readonly
Returns the value of attribute t.
Attributes inherited from Noun
Instance Method Summary collapse
- #==(another_cell) ⇒ Object
- #ary ⇒ Object
- #at(index:) ⇒ Object
- #atom? ⇒ Boolean
- #cell? ⇒ Boolean
-
#initialize(head:, tail:) ⇒ Cell
constructor
A new instance of Cell.
Methods inherited from Noun
Constructor Details
#initialize(head:, tail:) ⇒ Cell
Returns a new instance of Cell.
7 8 9 10 |
# File 'lib/nockr/cell.rb', line 7 def initialize(head:, tail:) @h = head @t = tail end |
Instance Attribute Details
#h ⇒ Object (readonly)
Returns the value of attribute h.
5 6 7 |
# File 'lib/nockr/cell.rb', line 5 def h @h end |
#t ⇒ Object (readonly)
Returns the value of attribute t.
5 6 7 |
# File 'lib/nockr/cell.rb', line 5 def t @t end |
Instance Method Details
#==(another_cell) ⇒ Object
12 13 14 |
# File 'lib/nockr/cell.rb', line 12 def ==(another_cell) another_cell.h == self.h && another_cell.t == self.t end |
#ary ⇒ Object
16 17 18 |
# File 'lib/nockr/cell.rb', line 16 def ary [@h.cell? ? @h.ary : @h.i, @t.cell? ? @t.ary : @t.i] end |
#at(index:) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/nockr/cell.rb', line 20 def at(index:) raise ArgumentError.new("Invalid Index.") if index < 1 || index > 3 return self if 1 == index return @h if 2 == index return @t if 3 == index end |
#atom? ⇒ Boolean
27 28 29 |
# File 'lib/nockr/cell.rb', line 27 def atom? false end |
#cell? ⇒ Boolean
31 32 33 |
# File 'lib/nockr/cell.rb', line 31 def cell? true end |