Class Schedule::Month
In: app/models/schedule/month.rb
Parent: Object

Methods

add   monday_of_week   name_abbr   new   to_s  

Attributes

date  [R] 
name  [R]  January, February …
weeks  [R]  List of Weeks

Public Class methods

[Source]

    # File app/models/schedule/month.rb, line 13
13:     def initialize(year, month)
14:       @year = year
15:       @month = month
16:       @name = Date::MONTHNAMES[month]
17:       @name_abbr = Date::ABBR_MONTHNAMES[month]
18:       @weeks = []
19:       @date = Date.new(year, month, 1)
20:       day = monday_of_week(@date)
21:       end_of_month = Date.new(year, month).to_time.at_end_of_month
22:       until day.to_time > end_of_month
23:         @weeks << Week.new(self, day)
24:         day = day + 7
25:       end
26:     end

Public Instance methods

[Source]

    # File app/models/schedule/month.rb, line 40
40:     def add(event)
41:       day_of_month = event.date.day
42:       @weeks.each do |week|
43:         week.days.each do |day|
44:           if !day.other_month? && day_of_month == day.day_of_month
45:             day.events << event
46:             return
47:           end
48:         end
49:       end
50:     end

Monday of this week‘s day as a number

[Source]

    # File app/models/schedule/month.rb, line 33
33:     def monday_of_week(day)
34:       until day.wday == 0
35:         day = day - 1
36:       end
37:       day
38:     end

[Source]

    # File app/models/schedule/month.rb, line 28
28:     def name_abbr
29:       @name_abbr
30:     end

[Source]

    # File app/models/schedule/month.rb, line 52
52:     def to_s
53:       "#<Schedule::Month #{name} #{date.strftime('%x') if date}>"
54:     end

[Validate]