Class: TExp::DayOfWeek
Instance Attribute Summary collapse
-
#days ⇒ Object
readonly
Returns the value of attribute days.
Instance Method Summary collapse
-
#encode(codes) ⇒ Object
Encode the temporal expression into
codes
. -
#includes?(date) ⇒ Boolean
Is
date
included in the temporal expression. -
#initialize(days) ⇒ DayOfWeek
constructor
A new instance of DayOfWeek.
-
#inspect ⇒ Object
Human readable version of the temporal expression.
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
#days ⇒ Object (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.
12 13 14 |
# File 'lib/texp/day_of_week.rb', line 12 def includes?(date) @days.include?(date.wday) end |
#inspect ⇒ Object
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 |