Class: Calorie::Week
- Inherits:
-
Object
- Object
- Calorie::Week
- Defined in:
- lib/calorie/week.rb
Instance Attribute Summary collapse
-
#days ⇒ Object
readonly
Returns the value of attribute days.
Instance Method Summary collapse
-
#initialize(days) ⇒ Week
constructor
A new instance of Week.
- #number ⇒ Object
- #thursday ⇒ Object
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
#days ⇒ Object (readonly)
Returns the value of attribute days.
4 5 6 |
# File 'lib/calorie/week.rb', line 4 def days @days end |
Instance Method Details
#number ⇒ Object
9 10 11 |
# File 'lib/calorie/week.rb', line 9 def number (thursday.date.yday / 7.0).ceil end |
#thursday ⇒ Object
13 14 15 16 17 |
# File 'lib/calorie/week.rb', line 13 def thursday days.each do |day| return day if day.date.thursday? end end |