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 Attribute Summary collapse

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.



738
739
740
741
# File 'lib/runt/temporalexpression.rb', line 738

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

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



736
737
738
# File 'lib/runt/temporalexpression.rb', line 736

def range
  @range
end

Instance Method Details

#==(o) ⇒ Object



743
744
745
# File 'lib/runt/temporalexpression.rb', line 743

def ==(o)
  o.is_a?(REMonth) ? range == o.range : super(o)
end

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


747
748
749
# File 'lib/runt/temporalexpression.rb', line 747

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

#to_sObject



751
752
753
# File 'lib/runt/temporalexpression.rb', line 751

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