class Repeatable::Expression::RangeInYear
Attributes
end_day[R]
end_month[R]
start_day[R]
start_month[R]
Public Class Methods
new(start_month:, end_month: start_month, start_day: 0, end_day: 0)
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 14 def initialize(start_month:, end_month: start_month, start_day: 0, end_day: 0) @start_month = start_month @end_month = end_month @start_day = start_day @end_day = end_day end
Public Instance Methods
include?(date)
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 22 def include?(date) return true if months_include?(date) if start_month == end_month start_month_include?(date) && end_month_include?(date) else start_month_include?(date) || end_month_include?(date) end end
Private Instance Methods
end_month_include?(date)
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 57 def end_month_include?(date) date.month == end_month && (end_day == 0 || date.day <= end_day) end
hash_value()
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 62 def hash_value args = {start_month: start_month} args[:end_month] = end_month unless end_month == start_month args[:start_day] = start_day unless start_day.zero? args[:end_day] = end_day unless end_day.zero? args end
months_include?(date)
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 47 def months_include?(date) date.month > start_month && date.month < end_month end
start_month_include?(date)
click to toggle source
# File lib/repeatable/expression/range_in_year.rb, line 52 def start_month_include?(date) date.month == start_month && (start_day == 0 || date.day >= start_day) end