Class: Scheduling::Quarterly

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#qdayObject

Returns the value of attribute qday

Returns:

  • (Object)

    the current value of qday



57
58
59
# File 'lib/scheduling/regularity/quarterly.rb', line 57

def qday
  @qday
end

Instance Method Details

#occurances(time_range) ⇒ Object

Raises:

  • (RangeDecreasingError)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/scheduling/regularity/quarterly.rb', line 58

def occurances time_range
  raise RangeDecreasingError if time_range.decreasing?
  cur = Date.quarterly(time_range.min.year, time_range.min.quarter, qday)

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

  occurances = []

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

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

  return occurances
end