Class: TimeRange::MonthEnumerator
- Inherits:
-
Object
- Object
- TimeRange::MonthEnumerator
- Includes:
- Enumerable
- Defined in:
- lib/3scale_time_range.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(range, step) ⇒ MonthEnumerator
constructor
A new instance of MonthEnumerator.
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
#each ⇒ Object
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 |