Class: Runt::EveryTE
- Inherits:
-
Object
- Object
- Runt::EveryTE
- Includes:
- TExpr
- Defined in:
- lib/runt/temporalexpression.rb
Overview
Using the precision from the supplied start argument and the its date value, matches every n number of time units thereafter.
Instance Method Summary collapse
- #include?(date) ⇒ Boolean
-
#initialize(start, n, precision = nil) ⇒ EveryTE
constructor
A new instance of EveryTE.
- #to_s ⇒ Object
Methods included from TExpr
#&, #-, #and, #dates, #minus, #or, #|
Constructor Details
#initialize(start, n, precision = nil) ⇒ EveryTE
Returns a new instance of EveryTE.
688 689 690 691 692 693 |
# File 'lib/runt/temporalexpression.rb', line 688 def initialize(start,n,precision=nil) @start=start @interval=n # Use the precision of the start date by default @precision=precision || @start.date_precision end |
Instance Method Details
#include?(date) ⇒ Boolean
695 696 697 698 699 700 701 702 703 |
# File 'lib/runt/temporalexpression.rb', line 695 def include?(date) i=DPrecision.to_p(@start,@precision) d=DPrecision.to_p(date,@precision) while i<=d return true if i.eql?(d) i=i+@interval end false end |
#to_s ⇒ Object
705 706 707 |
# File 'lib/runt/temporalexpression.rb', line 705 def to_s "every #{@interval} #{@precision.label.downcase}s starting #{Runt.format_date(@start)}" end |