Class: OnCalendar::Condition::Year

Inherits:
Base
  • Object
show all
Defined in:
lib/on_calendar/condition/year.rb

Constant Summary collapse

RANGE =
(1970..2200)

Instance Attribute Summary

Attributes inherited from Base

#base, #step, #wildcard

Instance Method Summary collapse

Methods inherited from Base

#distance_to_next, #match?, #range, range_bounds, #valid?

Constructor Details

#initialize(base: nil, step: nil, wildcard: false) ⇒ Year

Returns a new instance of Year.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/on_calendar/condition/year.rb', line 8

def initialize(base: nil, step: nil, wildcard: false)
  # Translate short year to long
  unless base.nil?
    if base.is_a?(Range)
      values = [
        translate_short_year(base.begin),
        translate_short_year(base.end)
      ]
      base = (values.min..values.max)
    else
      base = translate_short_year(base)
    end
  end
  super
end