Class: Runt::WIMonth
- Inherits:
-
Object
- Object
- Runt::WIMonth
- Includes:
- TExpr, TExprUtils
- Defined in:
- lib/runt/temporalexpression.rb
Overview
Constant Summary collapse
- VALID_RANGE =
-2..5
Instance Method Summary collapse
- #include?(date) ⇒ Boolean
-
#initialize(ordinal) ⇒ WIMonth
constructor
A new instance of WIMonth.
- #to_s ⇒ Object
Methods included from TExprUtils
#days_left_in_month, #max_day_of_month, #week_from_end_matches?, #week_from_start_matches?, #week_in_month, #week_matches?
Methods included from TExpr
#&, #-, #and, #dates, #minus, #or, #|
Constructor Details
#initialize(ordinal) ⇒ WIMonth
Returns a new instance of WIMonth.
636 637 638 639 640 641 |
# File 'lib/runt/temporalexpression.rb', line 636 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
643 644 645 |
# File 'lib/runt/temporalexpression.rb', line 643 def include?(date) week_matches?(@ordinal,date) end |
#to_s ⇒ Object
647 648 649 |
# File 'lib/runt/temporalexpression.rb', line 647 def to_s "#{Runt.ordinalize(@ordinal)} week of any month" end |