Class: Dev::DateRange::Daily
- Defined in:
- lib/firespring_dev_commands/daterange.rb
Overview
Class contains methods for calculating a date range with an daily interval
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
-
#current ⇒ Object
The daily interval for the current date.
-
#initialize(date = nil) ⇒ Daily
constructor
A new instance of Daily.
-
#next ⇒ Object
The daily interval after the current date.
-
#previous ⇒ Object
The daily interval previous to the current date.
Constructor Details
#initialize(date = nil) ⇒ Daily
Returns a new instance of Daily.
35 36 37 |
# File 'lib/firespring_dev_commands/daterange.rb', line 35 def initialize(date = nil) @date = date || DateTime.now end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
33 34 35 |
# File 'lib/firespring_dev_commands/daterange.rb', line 33 def date @date end |
Instance Method Details
#current ⇒ Object
The daily interval for the current date
46 47 48 49 50 |
# File 'lib/firespring_dev_commands/daterange.rb', line 46 def current start = date.beginning_of_day stop = date.end_of_day [start, stop] end |
#next ⇒ Object
The daily interval after the current date
53 54 55 56 |
# File 'lib/firespring_dev_commands/daterange.rb', line 53 def next @date = date.end_of_day + 1 current end |
#previous ⇒ Object
The daily interval previous to the current date
40 41 42 43 |
# File 'lib/firespring_dev_commands/daterange.rb', line 40 def previous @date = date.beginning_of_day - 1 current end |