Class: Dev::DateRange::Yearly

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dateObject

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

#currentObject

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

#nextObject

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

#previousObject

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