Class: Dev::DateRange::Quarterly
- 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
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
-
#current ⇒ Object
The quarterly interval for the current date.
-
#initialize(date = nil) ⇒ Quarterly
constructor
A new instance of Quarterly.
-
#next ⇒ Object
The quarterly interval after the current date.
-
#previous ⇒ Object
The quarterly interval previous to the current date.
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
#date ⇒ Object
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
#current ⇒ Object
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 |
#next ⇒ Object
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 |
#previous ⇒ Object
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 |