Class: Hiccup::Inferable::DatesEnumerator
- Inherits:
-
Object
- Object
- Hiccup::Inferable::DatesEnumerator
- Defined in:
- lib/hiccup/inferable/dates_enumerator.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(dates) ⇒ DatesEnumerator
constructor
A new instance of DatesEnumerator.
- #next ⇒ Object
- #rewind_by(n) ⇒ Object
Constructor Details
#initialize(dates) ⇒ DatesEnumerator
Returns a new instance of DatesEnumerator.
5 6 7 8 9 |
# File 'lib/hiccup/inferable/dates_enumerator.rb', line 5 def initialize(dates) @dates = dates @last_index = @dates.length - 1 @index = -1 end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
11 12 13 |
# File 'lib/hiccup/inferable/dates_enumerator.rb', line 11 def index @index end |
Instance Method Details
#done? ⇒ Boolean
13 14 15 |
# File 'lib/hiccup/inferable/dates_enumerator.rb', line 13 def done? @index == @last_index end |
#next ⇒ Object
17 18 19 20 21 |
# File 'lib/hiccup/inferable/dates_enumerator.rb', line 17 def next @index += 1 raise OutOfRangeException if @index > @last_index @dates[@index] end |
#rewind_by(n) ⇒ Object
23 24 25 26 |
# File 'lib/hiccup/inferable/dates_enumerator.rb', line 23 def rewind_by(n) @index -= n @index = -1 if @index < -1 end |