Class: Dev::DateRange::Monthly

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date = nil) ⇒ Monthly

Returns a new instance of Monthly.



91
92
93
# File 'lib/firespring_dev_commands/daterange.rb', line 91

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

Instance Attribute Details

#dateObject

Returns the value of attribute date.



89
90
91
# File 'lib/firespring_dev_commands/daterange.rb', line 89

def date
  @date
end

Instance Method Details

#currentObject

The monthly interval for the current date



102
103
104
105
106
# File 'lib/firespring_dev_commands/daterange.rb', line 102

def current
  start = date.beginning_of_month
  stop = date.end_of_month
  [start, stop]
end

#nextObject

The monthly interval after the current date



109
110
111
112
# File 'lib/firespring_dev_commands/daterange.rb', line 109

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

#previousObject

The monthly interval previous to the current date



96
97
98
99
# File 'lib/firespring_dev_commands/daterange.rb', line 96

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