Class: DoubleLinkedList::Sequence
- Inherits:
-
Object
- Object
- DoubleLinkedList::Sequence
- Defined in:
- lib/double_linked_list/sequence.rb
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Instance Method Summary collapse
-
#initialize(head:, last:) ⇒ Sequence
constructor
A new instance of Sequence.
- #next ⇒ Object
- #next? ⇒ Boolean
Constructor Details
#initialize(head:, last:) ⇒ Sequence
Returns a new instance of Sequence.
4 5 6 7 |
# File 'lib/double_linked_list/sequence.rb', line 4 def initialize(head:, last:) @head = head @last = last end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
3 4 5 |
# File 'lib/double_linked_list/sequence.rb', line 3 def head @head end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
3 4 5 |
# File 'lib/double_linked_list/sequence.rb', line 3 def last @last end |
Instance Method Details
#next ⇒ Object
9 10 11 12 |
# File 'lib/double_linked_list/sequence.rb', line 9 def next return unless next? last.next end |
#next? ⇒ Boolean
14 15 16 |
# File 'lib/double_linked_list/sequence.rb', line 14 def next? last.next ? true : false end |