Class: Campa::Node
- Inherits:
-
Object
- Object
- Campa::Node
- Defined in:
- lib/campa/node.rb
Overview
A node containing a value to form a linked List.
Instance Attribute Summary collapse
-
#next_node ⇒ Object
Returns the value of attribute next_node.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(value:, next_node: nil) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(value:, next_node: nil) ⇒ Node
Returns a new instance of Node.
10 11 12 13 |
# File 'lib/campa/node.rb', line 10 def initialize(value:, next_node: nil) @value = value @next_node = next_node end |
Instance Attribute Details
#next_node ⇒ Object
Returns the value of attribute next_node.
4 5 6 |
# File 'lib/campa/node.rb', line 4 def next_node @next_node end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/campa/node.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if #value is #== on both Campa::Node.
17 18 19 20 21 |
# File 'lib/campa/node.rb', line 17 def ==(other) return false if !other.is_a?(Node) value == other.value end |