Class: Dev::DateRange::Yearly
- Defined in:
- lib/firespring_dev_commands/daterange.rb
Overview
Class contains methods for calculating a date range with an yearly interval
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
-
#current ⇒ Object
The yearly interval for the current date.
-
#initialize(date = nil) ⇒ Yearly
constructor
A new instance of Yearly.
-
#next ⇒ Object
The yearly interval after the current date.
-
#previous ⇒ Object
The yearly interval previous to the current date.
Constructor Details
#initialize(date = nil) ⇒ Yearly
Returns a new instance of Yearly.
147 148 149 |
# File 'lib/firespring_dev_commands/daterange.rb', line 147 def initialize(date = nil) @date = date || DateTime.now end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
145 146 147 |
# File 'lib/firespring_dev_commands/daterange.rb', line 145 def date @date end |
Instance Method Details
#current ⇒ Object
The yearly interval for the current date
158 159 160 161 162 |
# File 'lib/firespring_dev_commands/daterange.rb', line 158 def current start = date.beginning_of_year stop = date.end_of_year [start, stop] end |
#next ⇒ Object
The yearly interval after the current date
165 166 167 168 |
# File 'lib/firespring_dev_commands/daterange.rb', line 165 def next @date = date.end_of_year + 1 current end |
#previous ⇒ Object
The yearly interval previous to the current date
152 153 154 155 |
# File 'lib/firespring_dev_commands/daterange.rb', line 152 def previous @date = date.beginning_of_year - 1 current end |