Class: Runt::DayIntervalTE
- Inherits:
-
Object
- Object
- Runt::DayIntervalTE
- 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 Attribute Summary collapse
-
#base_date ⇒ Object
readonly
Returns the value of attribute base_date.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #include?(date) ⇒ Boolean
-
#initialize(base_date, n) ⇒ DayIntervalTE
constructor
A new instance of DayIntervalTE.
- #to_s ⇒ Object
Methods included from TExpr
#&, #-, #and, #dates, #minus, #or, #|
Constructor Details
#initialize(base_date, n) ⇒ DayIntervalTE
Returns a new instance of DayIntervalTE.
804 805 806 807 |
# File 'lib/runt/temporalexpression.rb', line 804 def initialize(base_date,n) @base_date = DPrecision.to_p(base_date,DPrecision::DAY) @interval = n end |
Instance Attribute Details
#base_date ⇒ Object (readonly)
Returns the value of attribute base_date.
802 803 804 |
# File 'lib/runt/temporalexpression.rb', line 802 def base_date @base_date end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
802 803 804 |
# File 'lib/runt/temporalexpression.rb', line 802 def interval @interval end |
Instance Method Details
#==(o) ⇒ Object
809 810 811 |
# File 'lib/runt/temporalexpression.rb', line 809 def ==(o) o.is_a?(DayIntervalTE) ? base_date == o.base_date && interval == o.interval : super(o) end |
#include?(date) ⇒ Boolean
813 814 815 |
# File 'lib/runt/temporalexpression.rb', line 813 def include?(date) return ((DPrecision.to_p(date,DPrecision::DAY) - @base_date).to_i % @interval == 0) end |
#to_s ⇒ Object
817 818 819 |
# File 'lib/runt/temporalexpression.rb', line 817 def to_s "every #{Runt.ordinalize(@interval)} day after #{Runt.format_date(@base_date)}" end |