Class: Runt::DIMonth
Overview
TExpr that provides support for building a temporal expression using the form:
DIMonth.new(1,0)
where the first argument is the week of the month and the second argument is the wday of the week as defined by the ‘wday’ method in the standard library class Date.
A negative value for the week of the month argument will count backwards from the end of the month. So, to match the last Saturday of the month
DIMonth.new(-1,6)
Using constants defined in the base Runt module, you can re-write the first example above as:
DIMonth.new(First,Sunday)
and the second as:
DIMonth.new(Last,Saturday)
See also: Date, Runt
Instance Method Summary collapse
- #include?(date) ⇒ Boolean
-
#initialize(week_of_month_index, day_index) ⇒ DIMonth
constructor
A new instance of DIMonth.
- #print(date) ⇒ Object
- #to_s ⇒ Object
Methods inherited from TExpr
Constructor Details
#initialize(week_of_month_index, day_index) ⇒ DIMonth
Returns a new instance of DIMonth.
233 234 235 236 |
# File 'lib/runt/temporalexpression.rb', line 233 def initialize(week_of_month_index,day_index) @day_index = day_index @week_of_month_index = week_of_month_index end |
Instance Method Details
#include?(date) ⇒ Boolean
238 239 240 |
# File 'lib/runt/temporalexpression.rb', line 238 def include?(date) ( day_matches?(date) ) && ( week_matches?(@week_of_month_index,date) ) end |
#print(date) ⇒ Object
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/runt/temporalexpression.rb', line 246 def print(date) puts "DIMonth: #{date}" puts "include? == #{include?(date)}" puts "day_matches? == #{day_matches?(date)}" puts "week_matches? == #{week_matches?(date)}" puts "week_from_start_matches? == #{week_from_start_matches?(date)}" puts "week_from_end_matches? == #{week_from_end_matches?(date)}" puts "days_left_in_month == #{days_left_in_month(date)}" puts "max_day_of_month == #{max_day_of_month(date)}" end |
#to_s ⇒ Object
242 243 244 |
# File 'lib/runt/temporalexpression.rb', line 242 def to_s "DIMonth" end |