class Week
a week that always starts on a monday
Attributes
end_date[RW]
friday[RW]
monday[RW]
saturday[RW]
start_date[RW]
sunday[RW]
thursday[RW]
tuesday[RW]
wednesday[RW]
Public Class Methods
new(date = Date.today)
click to toggle source
# File lib/sane_week.rb, line 8 def initialize(date = Date.today) @start_date = find_monday(date) process_days end
Public Instance Methods
find_monday(date)
click to toggle source
gets the nearest past monday relative to the date given
# File lib/sane_week.rb, line 14 def find_monday date date.monday? ? date : find_monday(date - 1) end
Private Instance Methods
process_days()
click to toggle source
# File lib/sane_week.rb, line 24 def process_days days = {:monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} days.each { |day, val| instance_variable_set("@#{day}", @start_date + val ) } end