Module: EventCalendar::InstanceMethods
- Defined in:
- lib/event_calendar.rb
Overview
Instance Methods Override in your model as needed
Instance Method Summary collapse
- #adjust_all_day_dates ⇒ Object
- #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
#adjust_all_day_dates ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/event_calendar.rb', line 177 def adjust_all_day_dates if self.all_day self.start_at = self.start_at.beginning_of_day if self.end_at self.end_at = self.end_at.beginning_of_day + 1.day - 1.second else self.end_at = self.start_at + 1.day - 1.second end end end |
#all_day ⇒ Object
142 143 144 |
# File 'lib/event_calendar.rb', line 142 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
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/event_calendar.rb', line 156 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
146 147 148 |
# File 'lib/event_calendar.rb', line 146 def color self[:color] || '#9aa4ad' end |
#day ⇒ Object
138 139 140 |
# File 'lib/event_calendar.rb', line 138 def day date.day end |
#days ⇒ Object
150 151 152 |
# File 'lib/event_calendar.rb', line 150 def days end_at.to_date - start_at.to_date end |
#month ⇒ Object
134 135 136 |
# File 'lib/event_calendar.rb', line 134 def month date.month end |
#year ⇒ Object
130 131 132 |
# File 'lib/event_calendar.rb', line 130 def year date.year end |