Class: X_List::ListIterator
- Inherits:
-
Object
- Object
- X_List::ListIterator
- Defined in:
- lib/lib/x_list/list_iterator.rb
Instance Attribute Summary collapse
-
#head ⇒ Object
protected - in ruby this doesn’t play well with static/inline methods.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
- #_next ⇒ Object
- #has_next ⇒ Object
-
#initialize(head) ⇒ ListIterator
constructor
A new instance of ListIterator.
Constructor Details
#initialize(head) ⇒ ListIterator
Returns a new instance of ListIterator.
7 8 9 10 |
# File 'lib/lib/x_list/list_iterator.rb', line 7 def initialize(head) @head = head @val = nil end |
Instance Attribute Details
#head ⇒ Object
protected - in ruby this doesn’t play well with static/inline methods
14 15 16 |
# File 'lib/lib/x_list/list_iterator.rb', line 14 def head @head end |
#val ⇒ Object
Returns the value of attribute val.
15 16 17 |
# File 'lib/lib/x_list/list_iterator.rb', line 15 def val @val end |
Instance Method Details
#_next ⇒ Object
23 24 25 26 27 |
# File 'lib/lib/x_list/list_iterator.rb', line 23 def _next @val = @head[0] @head = @head[1] @val end |
#has_next ⇒ Object
19 20 21 |
# File 'lib/lib/x_list/list_iterator.rb', line 19 def has_next @head != nil end |