Parent

Included Modules

Runt::REDay

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.

NOTE: By default, this class will match any date expression whose precision is less than or equal to DPrecision::DAY. To override this behavior, pass the optional fifth constructor argument the value: false.

When the less_precise_match argument is true, the date-like object passed to :include? will be “promoted” to DPrecision::MINUTE if it has a precision of DPrecision::DAY or less.

Constants

ANY_DATE
CURRENT
NEXT

Attributes

range[R]
spans_midnight[R]

Public Class Methods

new(start_hour, start_minute, end_hour, end_minute, less_precise_match=true) click to toggle source
# File lib/runt/temporalexpression.rb, line 623
def initialize(start_hour, start_minute, end_hour, end_minute, less_precise_match=true)

  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
  @less_precise_match = less_precise_match
end

Public Instance Methods

==(o) click to toggle source
# File lib/runt/temporalexpression.rb, line 638
def ==(o)
  o.is_a?(REDay) ? spans_midnight == o.spans_midnight && range == o.range : super(o)
end
include?(date) click to toggle source
# File lib/runt/temporalexpression.rb, line 642
def include?(date)
  # 
  # If @less_precise_match == true and the precision of the argument
  #  is day or greater, then the result is always true
  return true if @less_precise_match && less_precise?(date)
      
      date_to_use = ensure_precision(date)
  
      if(@spans_midnight&&date_to_use.hour<12) then
    #Assume next day
    return @range.include?(get_next(date_to_use.hour,date_to_use.min))
  end

  #Same day
  return @range.include?(get_current(date_to_use.hour,date_to_use.min))
end
to_s() click to toggle source
# File lib/runt/temporalexpression.rb, line 659
def to_s
  "from #{Runt.format_time(@range.begin)} to #{Runt.format_time(@range.end)} daily"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.