Class: Scheduling::Yearly

Inherits:
Struct
  • Object
show all
Defined in:
lib/scheduling/regularity/yearly.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mdayObject

Returns the value of attribute mday

Returns:

  • (Object)

    the current value of mday



4
5
6
# File 'lib/scheduling/regularity/yearly.rb', line 4

def mday
  @mday
end

#monthObject

Returns the value of attribute month

Returns:

  • (Object)

    the current value of month



4
5
6
# File 'lib/scheduling/regularity/yearly.rb', line 4

def month
  @month
end

Instance Method Details

#occurances(time_range) ⇒ Object

Raises:

  • (RangeDecreasingError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/scheduling/regularity/yearly.rb', line 5

def occurances time_range
  raise RangeDecreasingError if time_range.decreasing?
  cur = Date.new(time_range.min.year, month, mday)

  start = time_range.min
  if cur < start
    cur = cur.next_year
  end

  occurances = []

  stop = time_range.last
  if time_range.exclude_end?
    stop -= 1
  end

  while cur <= stop
    occurances.push cur
    cur = cur.next_year
  end

  return occurances
end