Module: EventCalendar::InstanceMethods
- Defined in:
- lib/event_calendar.rb
Overview
Instance Methods Override in your model as needed
Instance Method Summary collapse
- #all_day ⇒ Object
-
#clip_range(start_d, end_d) ⇒ Object
start_d - start of the month, or start of the week end_d - end of the month, or end of the week.
- #color ⇒ Object
- #day ⇒ Object
- #days ⇒ Object
- #month ⇒ Object
- #year ⇒ Object
Instance Method Details
#all_day ⇒ Object
137 138 139 |
# File 'lib/event_calendar.rb', line 137 def all_day self[:all_day] end |
#clip_range(start_d, end_d) ⇒ Object
start_d - start of the month, or start of the week end_d - end of the month, or end of the week
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/event_calendar.rb', line 151 def clip_range(start_d, end_d) # make sure we are comparing date objects to date objects, # otherwise timezones can cause problems start_at_d = start_at.to_date end_at_d = end_at.to_date # Clip start date, make sure it also ends on or after the start range if (start_at_d < start_d and end_at_d >= start_d) clipped_start = start_d else clipped_start = start_at_d end # Clip end date if (end_at_d > end_d) clipped_end = end_d else clipped_end = end_at_d end [clipped_start, clipped_end] end |
#color ⇒ Object
141 142 143 |
# File 'lib/event_calendar.rb', line 141 def color self[:color] || '#9aa4ad' end |
#day ⇒ Object
133 134 135 |
# File 'lib/event_calendar.rb', line 133 def day date.day end |
#days ⇒ Object
145 146 147 |
# File 'lib/event_calendar.rb', line 145 def days end_at.to_date - start_at.to_date end |
#month ⇒ Object
129 130 131 |
# File 'lib/event_calendar.rb', line 129 def month date.month end |
#year ⇒ Object
125 126 127 |
# File 'lib/event_calendar.rb', line 125 def year date.year end |