Class: Dev::DateRange::Weekly
- Defined in:
- lib/firespring_dev_commands/daterange.rb
Overview
Class contains methods for calculating a date range with an weekly interval
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
-
#current ⇒ Object
The weekly interval for the current date.
-
#initialize(date = nil) ⇒ Weekly
constructor
A new instance of Weekly.
-
#next ⇒ Object
The weekly interval after the current date.
-
#previous ⇒ Object
The weekly interval previous to the current date.
Constructor Details
#initialize(date = nil) ⇒ Weekly
Returns a new instance of Weekly.
63 64 65 |
# File 'lib/firespring_dev_commands/daterange.rb', line 63 def initialize(date = nil) @date = date || DateTime.now end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
61 62 63 |
# File 'lib/firespring_dev_commands/daterange.rb', line 61 def date @date end |
Instance Method Details
#current ⇒ Object
The weekly interval for the current date
74 75 76 77 78 |
# File 'lib/firespring_dev_commands/daterange.rb', line 74 def current start = date.beginning_of_week stop = date.end_of_week [start, stop] end |
#next ⇒ Object
The weekly interval after the current date
81 82 83 84 |
# File 'lib/firespring_dev_commands/daterange.rb', line 81 def next @date = date.end_of_week + 1 current end |
#previous ⇒ Object
The weekly interval previous to the current date
68 69 70 71 |
# File 'lib/firespring_dev_commands/daterange.rb', line 68 def previous @date = date.beginning_of_week - 1 current end |