Class: TExp::DayOfWeek

Inherits:
Base
  • Object
show all
Defined in:
lib/texp/day_of_week.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#*, #+, #-, #-@, #each, #first_day_of_window, #include?, #last_day_of_window, parse_callback, #reanchor, register_parse_callback, #to_s, #window

Constructor Details

#initialize(days) ⇒ DayOfWeek

Returns a new instance of DayOfWeek.



7
8
9
# File 'lib/texp/day_of_week.rb', line 7

def initialize(days)
  @days = listize(days)
end

Instance Attribute Details

#daysObject (readonly)

Returns the value of attribute days.



3
4
5
# File 'lib/texp/day_of_week.rb', line 3

def days
  @days
end

Instance Method Details

#encode(codes) ⇒ Object

Encode the temporal expression into codes.



23
24
25
26
# File 'lib/texp/day_of_week.rb', line 23

def encode(codes)
  encode_list(codes, @days)
  codes << encoding_token
end

#includes?(date) ⇒ Boolean

Is date included in the temporal expression.

Returns:

  • (Boolean)


12
13
14
# File 'lib/texp/day_of_week.rb', line 12

def includes?(date)
  @days.include?(date.wday)
end

#inspectObject

Human readable version of the temporal expression.



17
18
19
20
# File 'lib/texp/day_of_week.rb', line 17

def inspect
  "on " +
    humanize_list(@days, "and") { |d| Date::DAYNAMES[d] }
end