Class: Chrono::Iterator

Inherits:
Object
  • Object
show all
Defined in:
lib/chrono/iterator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Iterator

Returns a new instance of Iterator.



7
8
9
10
# File 'lib/chrono/iterator.rb', line 7

def initialize(source, options = {})
  @source = source
  @now = options[:now] || Time.now
end

Instance Attribute Details

#nowObject

Returns the value of attribute now.



3
4
5
# File 'lib/chrono/iterator.rb', line 3

def now
  @now
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/chrono/iterator.rb', line 5

def source
  @source
end

Instance Method Details

#nextObject



12
13
14
# File 'lib/chrono/iterator.rb', line 12

def next
  self.now = NextTime.new(now: now, source: source).to_time
end