Class: Runt::WIMonth

Inherits:
TExpr
  • Object
show all
Defined in:
lib/runt/temporalexpression.rb

Overview

TExpr that matches the week in a month. For example:

   WIMonth.new(1)

See also: Date

Constant Summary collapse

VALID_RANGE =
-2..5

Instance Method Summary collapse

Methods inherited from TExpr

#&, #-, #and, #minus, #or, #to_s, #|

Constructor Details

#initialize(ordinal) ⇒ WIMonth

Returns a new instance of WIMonth.



454
455
456
457
458
459
# File 'lib/runt/temporalexpression.rb', line 454

def initialize(ordinal)
  unless VALID_RANGE.include?(ordinal)
    raise ArgumentError, 'invalid ordinal week of month'
  end
  @ordinal = ordinal
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


461
462
463
# File 'lib/runt/temporalexpression.rb', line 461

def include?(date)
  week_matches?(@ordinal,date)
end