module LucaSupport::Range
Partial range operation
Public Instance Methods
by_month(step = nil, from: nil, to: nil) { |cursor_start, cursor_end| ... }
click to toggle source
# File lib/luca_support/range.rb, line 11 def by_month(step = nil, from: nil, to: nil) return enum_for(:by_month, step, from: from, to: to) unless block_given? from ||= @start_date to ||= @end_date self.class.term_by_month(from, to, step || 1).each do |date| @cursor_start = date @cursor_end = step.nil? ? date : [date.next_month(step - 1), to].min yield @cursor_start, @cursor_end end end