Class: Runt::WIMonth
- Inherits:
-
Object
- Object
- Runt::WIMonth
- Includes:
- TExpr, TExprUtils
- Defined in:
- lib/runt/temporalexpression.rb
Overview
TExpr that matches the week in a month. For example:
WIMonth.new(1)
See also: Date
FIXME .dates mixin seems functionally broken
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.
630 631 632 633 634 635 |
# File 'lib/runt/temporalexpression.rb', line 630 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
637 638 639 |
# File 'lib/runt/temporalexpression.rb', line 637 def include?(date) week_matches?(@ordinal,date) end |
#to_s ⇒ Object
641 642 643 |
# File 'lib/runt/temporalexpression.rb', line 641 def to_s "#{Runt.ordinalize(@ordinal)} week of any month" end |