Class: Week

Inherits:
Object
  • Object
show all
Includes:
Comparable, DateRange
Defined in:
lib/funtimes/week.rb

Constant Summary collapse

START_DAY =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DateRange

#&, #days, #encompasses, #intersects, #months, #number_of_days_in, #quarters, #same_range_as, #weeks, #|

Constructor Details

#initialize(date) ⇒ Week

Returns a new instance of Week.



11
12
13
14
# File 'lib/funtimes/week.rb', line 11

def initialize(date)
  start_date = get_start_date(date)
  @start_date, @end_date = start_date, start_date + 6
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



5
6
7
# File 'lib/funtimes/week.rb', line 5

def end_date
  @end_date
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/funtimes/week.rb', line 5

def start_date
  @start_date
end

Class Method Details

.from(start_date) ⇒ Object



16
17
18
# File 'lib/funtimes/week.rb', line 16

def self.from(start_date)
  Week.new start_date
end

Instance Method Details

#<=>(other) ⇒ Object



20
21
22
# File 'lib/funtimes/week.rb', line 20

def <=> (other)
  @start_date <=> other.start_date 
end

#prevObject



28
29
30
# File 'lib/funtimes/week.rb', line 28

def prev
  Week.new(@start_date - 7)
end

#succObject



24
25
26
# File 'lib/funtimes/week.rb', line 24

def succ
  Week.new(@start_date + 7)
end