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 Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #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.
767 768 769 770 771 772 |
# File 'lib/runt/temporalexpression.rb', line 767 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 Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
765 766 767 |
# File 'lib/runt/temporalexpression.rb', line 765 def interval @interval end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
765 766 767 |
# File 'lib/runt/temporalexpression.rb', line 765 def precision @precision end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
765 766 767 |
# File 'lib/runt/temporalexpression.rb', line 765 def start @start end |
Instance Method Details
#==(o) ⇒ Object
774 775 776 |
# File 'lib/runt/temporalexpression.rb', line 774 def ==(o) o.is_a?(EveryTE) ? start == o.start && precision == o.precision && interval == o.interval : super(o) end |
#include?(date) ⇒ Boolean
778 779 780 781 782 783 784 785 786 |
# File 'lib/runt/temporalexpression.rb', line 778 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
788 789 790 |
# File 'lib/runt/temporalexpression.rb', line 788 def to_s "every #{@interval} #{@precision.label.downcase}s starting #{Runt.format_date(@start)}" end |