Class: TExp::DayOfMonth

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

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) ⇒ DayOfMonth

Returns a new instance of DayOfMonth.



5
6
7
# File 'lib/texp/day_of_month.rb', line 5

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

Instance Method Details

#encode(codes) ⇒ Object

Encode the temporal expression into codes.



21
22
23
24
# File 'lib/texp/day_of_month.rb', line 21

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

#includes?(date) ⇒ Boolean

Is date included in the temporal expression.

Returns:

  • (Boolean)


10
11
12
# File 'lib/texp/day_of_month.rb', line 10

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

#inspectObject

Human readable version of the temporal expression.



15
16
17
18
# File 'lib/texp/day_of_month.rb', line 15

def inspect
  "the day of the month is the " +
    ordinal_list(@days)
end