Class: Calendar
- Inherits:
-
Object
- Object
- Calendar
- Defined in:
- lib/generators/calendar/templates/calendar.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#day ⇒ Object
Returns the value of attribute day.
-
#nil_day ⇒ Object
Returns the value of attribute nil_day.
Instance Method Summary collapse
- #days_in_month ⇒ Object
-
#initialize(date = DateTime.now) ⇒ Calendar
constructor
A new instance of Calendar.
- #list_months ⇒ Object
- #list_weeks ⇒ Object
- #nil_days_in_month ⇒ Object
- #today ⇒ Object
Constructor Details
#initialize(date = DateTime.now) ⇒ Calendar
Returns a new instance of Calendar.
7 8 9 10 11 |
# File 'lib/generators/calendar/templates/calendar.rb', line 7 def initialize date = DateTime.now self.date = date.to_date self.day = 1 self.nil_day = 0 end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/generators/calendar/templates/calendar.rb', line 3 def date @date end |
#day ⇒ Object
Returns the value of attribute day.
4 5 6 |
# File 'lib/generators/calendar/templates/calendar.rb', line 4 def day @day end |
#nil_day ⇒ Object
Returns the value of attribute nil_day.
5 6 7 |
# File 'lib/generators/calendar/templates/calendar.rb', line 5 def nil_day @nil_day end |
Instance Method Details
#days_in_month ⇒ Object
17 18 19 |
# File 'lib/generators/calendar/templates/calendar.rb', line 17 def days_in_month [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] end |
#list_months ⇒ Object
29 30 31 |
# File 'lib/generators/calendar/templates/calendar.rb', line 29 def list_months [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] end |
#list_weeks ⇒ Object
25 26 27 |
# File 'lib/generators/calendar/templates/calendar.rb', line 25 def list_weeks ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] end |
#nil_days_in_month ⇒ Object
21 22 23 |
# File 'lib/generators/calendar/templates/calendar.rb', line 21 def nil_days_in_month self.date.beginning_of_month.wday end |
#today ⇒ Object
13 14 15 |
# File 'lib/generators/calendar/templates/calendar.rb', line 13 def today DateTime.now end |