Class: TExp::Week

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

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(weeks) ⇒ Week

Returns a new instance of Week.



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

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

Instance Method Details

#encode(codes) ⇒ Object

Encode the temporal expression into codes.



18
19
20
21
# File 'lib/texp/week.rb', line 18

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

#includes?(date) ⇒ Boolean

Is date included in the temporal expression.

Returns:

  • (Boolean)


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

def includes?(date)
  @weeks.include?(week_from_front(date)) ||
    @weeks.include?(week_from_back(date))
end

#inspectObject

Human readable version of the temporal expression.



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

def inspect
  "it is the " + ordinal_list(@weeks) + " week of the month"
end