Class: Dev::DateRange::Weekly

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

Instance Method Summary collapse

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

#dateObject

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

#currentObject

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

#nextObject

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

#previousObject

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