Class: TExp::Year

Inherits:
Base
  • Object
show all
Defined in:
lib/texp/year.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(years) ⇒ Year

Returns a new instance of Year.



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

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

Instance Method Details

#encode(codes) ⇒ Object

Encode the temporal expression into codes.



20
21
22
23
# File 'lib/texp/year.rb', line 20

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

#includes?(date) ⇒ Boolean

Is date included in the temporal expression.

Returns:

  • (Boolean)


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

def includes?(date)
  @years.include?(date.year)
end

#inspectObject

Human readable version of the temporal expression.



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

def inspect
  "the year is " + humanize_list(@years)
end