Class Runt::DIMonth
In: lib/runt/temporalexpression.rb
Parent: Object

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

Methods

include?   new   to_s  

Included Modules

TExpr TExprUtils

Public Class methods

[Source]

# File lib/runt/temporalexpression.rb, line 318
  def initialize(week_of_month_index,day_index)
    @day_index = day_index
    @week_of_month_index = week_of_month_index
  end

Public Instance methods

[Source]

# File lib/runt/temporalexpression.rb, line 323
  def include?(date)
    ( day_matches?(date) ) && ( week_matches?(@week_of_month_index,date) )
  end

[Source]

# File lib/runt/temporalexpression.rb, line 327
  def to_s
    "#{Runt.ordinalize(@week_of_month_index)} #{Runt.day_name(@day_index)} of the month"
  end

[Validate]