Class: Runt::DayIntervalTE

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

Overview

Using day precision dates, matches every n number of days after a given base date. All date arguments are converted to DPrecision::DAY precision.

Contributed by Ira Burton

Instance Method Summary collapse

Methods included from TExpr

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

Constructor Details

#initialize(base_date, n) ⇒ DayIntervalTE

Returns a new instance of DayIntervalTE.



719
720
721
722
# File 'lib/runt/temporalexpression.rb', line 719

def initialize(base_date,n)
  @base_date = DPrecision.to_p(base_date,DPrecision::DAY)
  @interval = n
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


724
725
726
# File 'lib/runt/temporalexpression.rb', line 724

def include?(date)
  return ((DPrecision.to_p(date,DPrecision::DAY) - @base_date).to_i % @interval == 0)   
end

#to_sObject



728
729
730
# File 'lib/runt/temporalexpression.rb', line 728

def to_s
  "every #{Runt.ordinalize(@interval)} day after #{Runt.format_date(@base_date)}"
end