Class: HTMLCalendar::Calendar
- Inherits:
-
Object
- Object
- HTMLCalendar::Calendar
- Defined in:
- lib/html_calendar/calendar.rb
Instance Attribute Summary collapse
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #in_month?(date) ⇒ Boolean
-
#initialize(template, month, options = {}) ⇒ Calendar
constructor
A new instance of Calendar.
- #prefix ⇒ Object
- #render_date(date) ⇒ Object
- #render_header ⇒ Object
- #renderable_date_range ⇒ Object
- #renderable_date_range_in_weeks ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#month ⇒ Object (readonly)
Returns the value of attribute month.
3 4 5 |
# File 'lib/html_calendar/calendar.rb', line 3 def month @month end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/html_calendar/calendar.rb', line 3 def @options end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'lib/html_calendar/calendar.rb', line 3 def template @template end |
Instance Method Details
#in_month?(date) ⇒ Boolean
35 36 37 |
# File 'lib/html_calendar/calendar.rb', line 35 def in_month?(date) date_range.include? date end |
#prefix ⇒ Object
39 40 41 |
# File 'lib/html_calendar/calendar.rb', line 39 def prefix self.class.name.underscore end |
#render_date(date) ⇒ Object
30 31 32 33 |
# File 'lib/html_calendar/calendar.rb', line 30 def render_date(date) partial_name = in_month?(date) ? 'day' : 'other_month_day' render partial_name, date: date, presenter: date_presenter_for(date) end |
#render_header ⇒ Object
26 27 28 |
# File 'lib/html_calendar/calendar.rb', line 26 def render_header render 'header', month: month end |
#renderable_date_range ⇒ Object
18 19 20 |
# File 'lib/html_calendar/calendar.rb', line 18 def renderable_date_range beginning_of_month.at_beginning_of_week(:sunday)..end_of_month.at_end_of_week(:sunday) end |
#renderable_date_range_in_weeks ⇒ Object
22 23 24 |
# File 'lib/html_calendar/calendar.rb', line 22 def renderable_date_range_in_weeks renderable_date_range.to_a.in_groups_of(7) end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/html_calendar/calendar.rb', line 14 def to_s render 'calendar', calendar: self end |