Class: Runt::REWeek

Inherits:
TExpr
  • Object
show all
Defined in:
lib/runt/temporalexpression.rb

Overview

TExpr that matches days of the week within one week only.

If start and end day are equal, the entire week will match true.

See also: Date

Constant Summary collapse

VALID_RANGE =
0..6

Instance Method Summary collapse

Methods inherited from TExpr

#&, #-, #and, #minus, #or, #|

Constructor Details

#initialize(start_day, end_day = 6) ⇒ REWeek

ArgumentError will be raised



312
313
314
315
316
317
# File 'lib/runt/temporalexpression.rb', line 312

def initialize(start_day,end_day=6)
super()
validate(start_day,end_day)
  @start_day = start_day
  @end_day = end_day
end

Instance Method Details

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


319
320
321
322
# File 'lib/runt/temporalexpression.rb', line 319

def include?(date)
  return true if  @start_day==@end_day
  @start_day<=date.wday && @end_day>=date.wday
end

#to_sObject



324
325
326
# File 'lib/runt/temporalexpression.rb', line 324

def to_s
  "REWeek"
end