Class: Runt::REMonth

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

Overview

TExpr that matches a range of dates within a month. For example:

REMonth.(12,28)

matches from the 12th thru the 28th of any month. If end_day==0 or is not given, start_day will define the range with that single day.

See also: Date

Instance Method Summary collapse

Methods included from TExpr

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

Constructor Details

#initialize(start_day, end_day = 0) ⇒ REMonth

Returns a new instance of REMonth.



665
666
667
668
# File 'lib/runt/temporalexpression.rb', line 665

def initialize(start_day, end_day=0)
  end_day=start_day if end_day==0
  @range = start_day..end_day
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


670
671
672
# File 'lib/runt/temporalexpression.rb', line 670

def include?(date)
  @range.include? date.mday
end

#to_sObject



674
675
676
# File 'lib/runt/temporalexpression.rb', line 674

def to_s
  "from the #{Runt.ordinalize(@range.begin)} to the #{Runt.ordinalize(@range.end)} monthly"
end