Class: Runt::REDay
- Inherits:
-
Object
- Object
- Runt::REDay
- Includes:
- TExpr
- Defined in:
- lib/runt/temporalexpression.rb
Overview
TExpr that matches periods of the day with minute precision. If the start hour is greater than the end hour, than end hour is assumed to be on the following day.
See also: Date
Constant Summary collapse
- CURRENT =
28
- NEXT =
29
- ANY_DATE =
PDate.day(2002,8,CURRENT)
Instance Method Summary collapse
- #include?(date) ⇒ Boolean
-
#initialize(start_hour, start_minute, end_hour, end_minute) ⇒ REDay
constructor
A new instance of REDay.
- #to_s ⇒ Object
Methods included from TExpr
#&, #-, #and, #dates, #minus, #or, #|
Constructor Details
#initialize(start_hour, start_minute, end_hour, end_minute) ⇒ REDay
Returns a new instance of REDay.
555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/runt/temporalexpression.rb', line 555 def initialize(start_hour, start_minute, end_hour, end_minute) start_time = PDate.min(ANY_DATE.year,ANY_DATE.month, ANY_DATE.day,start_hour,start_minute) if(@spans_midnight = spans_midnight?(start_hour, end_hour)) then end_time = get_next(end_hour,end_minute) else end_time = get_current(end_hour,end_minute) end @range = start_time..end_time end |
Instance Method Details
#include?(date) ⇒ Boolean
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/runt/temporalexpression.rb', line 569 def include?(date) # 2007-11-9: Not completely sure of the implications of commenting this # out but... # # If precision is day or greater, then the result is always true #return true if date.date_precision <= DPrecision::DAY if(@spans_midnight&&date.hour<12) then #Assume next day return @range.include?(get_next(date.hour,date.min)) end #Same day return @range.include?(get_current(date.hour,date.min)) end |
#to_s ⇒ Object
585 586 587 |
# File 'lib/runt/temporalexpression.rb', line 585 def to_s "from #{Runt.format_time(@range.begin)} to #{Runt.format_time(@range.end)} daily" end |