Class: Dev::DateRange::Daily

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

Instance Method Summary collapse

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

#dateObject

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

#currentObject

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

#nextObject

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

#previousObject

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