Class: Week

Inherits:
Object
  • Object
show all
Defined in:
lib/dude_weak.rb

Defined Under Namespace

Classes: Day

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ Week

Returns a new instance of Week.



9
10
11
12
# File 'lib/dude_weak.rb', line 9

def initialize(time)
  @time = time
  @date = time.to_date
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



7
8
9
# File 'lib/dude_weak.rb', line 7

def date
  @date
end

#timeObject

Returns the value of attribute time.



7
8
9
# File 'lib/dude_weak.rb', line 7

def time
  @time
end

Instance Method Details

#daysObject



34
35
36
37
38
39
# File 'lib/dude_weak.rb', line 34

def days
  @days ||= []
  return @days unless @days.empty?
  build_days
  @days
end

#mondayObject



30
31
32
# File 'lib/dude_weak.rb', line 30

def monday
  @time.monday
end

#nextObject



22
23
24
# File 'lib/dude_weak.rb', line 22

def next
  self.class.new(@date.next_week)
end

#numberObject



18
19
20
# File 'lib/dude_weak.rb', line 18

def number
  @date.cweek
end

#previousObject



26
27
28
# File 'lib/dude_weak.rb', line 26

def previous
  self.class.new(@date.prev_week)
end

#yearObject



14
15
16
# File 'lib/dude_weak.rb', line 14

def year
  @date.cwyear
end