Class: Week
- Inherits:
-
Object
- Object
- Week
- Defined in:
- lib/sane_week.rb
Overview
a week that always starts on a monday
Instance Attribute Summary collapse
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#friday ⇒ Object
Returns the value of attribute friday.
-
#monday ⇒ Object
Returns the value of attribute monday.
-
#saturday ⇒ Object
Returns the value of attribute saturday.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#sunday ⇒ Object
Returns the value of attribute sunday.
-
#thursday ⇒ Object
Returns the value of attribute thursday.
-
#tuesday ⇒ Object
Returns the value of attribute tuesday.
-
#wednesday ⇒ Object
Returns the value of attribute wednesday.
Instance Method Summary collapse
-
#find_monday(date) ⇒ Object
gets the nearest past monday relative to the date given.
-
#initialize(date = Date.today) ⇒ Week
constructor
A new instance of Week.
Constructor Details
#initialize(date = Date.today) ⇒ Week
Returns a new instance of Week.
8 9 10 11 |
# File 'lib/sane_week.rb', line 8 def initialize(date = Date.today) @start_date = find_monday(date) process_days end |
Instance Attribute Details
#end_date ⇒ Object
Returns the value of attribute end_date.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def end_date @end_date end |
#friday ⇒ Object
Returns the value of attribute friday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def friday @friday end |
#monday ⇒ Object
Returns the value of attribute monday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def monday @monday end |
#saturday ⇒ Object
Returns the value of attribute saturday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def saturday @saturday end |
#start_date ⇒ Object
Returns the value of attribute start_date.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def start_date @start_date end |
#sunday ⇒ Object
Returns the value of attribute sunday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def sunday @sunday end |
#thursday ⇒ Object
Returns the value of attribute thursday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def thursday @thursday end |
#tuesday ⇒ Object
Returns the value of attribute tuesday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def tuesday @tuesday end |
#wednesday ⇒ Object
Returns the value of attribute wednesday.
4 5 6 |
# File 'lib/sane_week.rb', line 4 def wednesday @wednesday end |
Instance Method Details
#find_monday(date) ⇒ Object
gets the nearest past monday relative to the date given
14 15 16 |
# File 'lib/sane_week.rb', line 14 def find_monday date date.monday? ? date : find_monday(date - 1) end |