Class: Calorie::Week

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(days) ⇒ Week

Returns a new instance of Week.



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

def initialize(days)
  @days = days
end

Instance Attribute Details

#daysObject (readonly)

Returns the value of attribute days.



4
5
6
# File 'lib/calorie/week.rb', line 4

def days
  @days
end

Instance Method Details

#each_day(&block) ⇒ Object



9
10
11
# File 'lib/calorie/week.rb', line 9

def each_day(&block)
  days.each {|day| block.call(day) }
end

#numberObject



13
14
15
# File 'lib/calorie/week.rb', line 13

def number
  (thursday.date.yday / 7.0).ceil
end

#thursdayObject



17
18
19
20
21
# File 'lib/calorie/week.rb', line 17

def thursday
  days.each do |day|
    return day if day.date.thursday?
  end
end