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