Class: TimeRange::MonthEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/3scale_time_range.rb

Instance Method Summary collapse

Constructor Details

#initialize(range, step) ⇒ MonthEnumerator

Returns a new instance of MonthEnumerator.



164
165
166
# File 'lib/3scale_time_range.rb', line 164

def initialize(range, step)
  @range = range
end

Instance Method Details

#eachObject



168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/3scale_time_range.rb', line 168

def each
  current = @range.begin
  last = @range.end
  last -= 1.month if @range.exclude_end?

  while current <= last
    yield(current)
    current = (current + 1.month).end_of_month
  end

  self
end