Class: Dev::DateRange::Quarterly

Inherits:
Object
  • Object
show all
Defined in:
lib/firespring_dev_commands/daterange.rb

Overview

Class contains methods for calculating a date range with an quarterly interval

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date = nil) ⇒ Quarterly

Returns a new instance of Quarterly.



119
120
121
# File 'lib/firespring_dev_commands/daterange.rb', line 119

def initialize(date = nil)
  @date = date || DateTime.now
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



117
118
119
# File 'lib/firespring_dev_commands/daterange.rb', line 117

def date
  @date
end

Instance Method Details

#currentObject

The quarterly interval for the current date



130
131
132
133
134
# File 'lib/firespring_dev_commands/daterange.rb', line 130

def current
  start = date.beginning_of_quarter
  stop = date.end_of_quarter
  [start, stop]
end

#nextObject

The quarterly interval after the current date



137
138
139
140
# File 'lib/firespring_dev_commands/daterange.rb', line 137

def next
  @date = date.end_of_quarter + 1
  current
end

#previousObject

The quarterly interval previous to the current date



124
125
126
127
# File 'lib/firespring_dev_commands/daterange.rb', line 124

def previous
  @date = date.beginning_of_quarter - 1
  current
end