class Runt::DIWeek

TExpr that matches days of the week where the first argument is an integer denoting the ordinal day of the week. Valid values are 0..6 where 0 == Sunday and 6==Saturday

For example:

DIWeek.new(0)

Using constants defined in the base Runt module, you can re-write the first example above as:

   DIWeek.new(Sunday)

See also: Date, Runt

Constants

VALID_RANGE

Attributes

ordinal_weekday[R]

Public Class Methods

new(ordinal_weekday) click to toggle source
# File lib/runt/temporalexpression.rb, line 392
def initialize(ordinal_weekday)
  unless VALID_RANGE.include?(ordinal_weekday)
    raise ArgumentError, 'invalid ordinal day of week'
  end
  @ordinal_weekday = ordinal_weekday
end

Public Instance Methods

==(o) click to toggle source
Calls superclass method
# File lib/runt/temporalexpression.rb, line 399
def ==(o)
  o.is_a?(DIWeek) ? ordinal_weekday == o.ordinal_weekday : super(o)
end
include?(date) click to toggle source
# File lib/runt/temporalexpression.rb, line 403
def include?(date)
  @ordinal_weekday == date.wday
end
to_s() click to toggle source
# File lib/runt/temporalexpression.rb, line 407
def to_s
  "#{Runt.day_name(@ordinal_weekday)}"
end