Class: Hiccup::Inferable::DatesEnumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/hiccup/inferable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dates) ⇒ DatesEnumerator

Returns a new instance of DatesEnumerator.



375
376
377
378
379
# File 'lib/hiccup/inferable.rb', line 375

def initialize(dates)
  @dates = dates
  @last_index = @dates.length - 1
  @index = -1
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



381
382
383
# File 'lib/hiccup/inferable.rb', line 381

def index
  @index
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


383
384
385
# File 'lib/hiccup/inferable.rb', line 383

def done?
  @index == @last_index
end

#nextObject

Raises:

  • (OutOfRangeException)


387
388
389
390
391
# File 'lib/hiccup/inferable.rb', line 387

def next
  @index += 1
  raise OutOfRangeException if @index > @last_index
  @dates[@index]
end

#rewind_by(n) ⇒ Object



393
394
395
396
# File 'lib/hiccup/inferable.rb', line 393

def rewind_by(n)
  @index -= n
  @index = -1 if @index < -1
end