Class: CalendarEntry
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CalendarEntry
- Defined in:
- app/models/calendar_entry.rb
Instance Method Summary collapse
- #date_display ⇒ Object
- #has_image? ⇒ Boolean
- #in_future? ⇒ Boolean
- #list_days(sep = ' ') ⇒ Object
- #no_days ⇒ Object
- #on_day(n) ⇒ Object
- #position ⇒ Object
- #url ⇒ Object
Instance Method Details
#date_display ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/calendar_entry.rb', line 48 def date_display dd = [] dd << self.start_date.to_formatted_s(:rfc822) dd << self.start_time.to_formatted_s(:time) if self.start_time if self.start_date != self.end_date dd << "to" dd << self.end_date.to_formatted_s(:rfc822) dd << self.end_time.to_formatted_s(:time) if self.end_time end dd.join(' ') end |
#has_image? ⇒ Boolean
67 68 69 |
# File 'app/models/calendar_entry.rb', line 67 def has_image? self.image.file? end |
#in_future? ⇒ Boolean
42 43 44 45 |
# File 'app/models/calendar_entry.rb', line 42 def in_future? the_date = self.end_date || self.start_date return the_date>Date.today end |
#list_days(sep = ' ') ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/calendar_entry.rb', line 22 def list_days(sep = ' ') d = [] d << "Sun" if self.on_0==1 d << "Mon" if self.on_1==1 d << "Tue" if self.on_2==1 d << "Wed" if self.on_3==1 d << "Thu" if self.on_4==1 d << "Fri" if self.on_5==1 d << "Sat" if self.on_6==1 return d.join(sep) end |
#no_days ⇒ Object
38 39 40 |
# File 'app/models/calendar_entry.rb', line 38 def no_days return self.on_0 + self.on_1 + self.on_2 + self.on_3 + self.on_4 + self.on_5 + self.on_6 == 0 end |
#on_day(n) ⇒ Object
34 35 36 |
# File 'app/models/calendar_entry.rb', line 34 def on_day(n) return self.send("on_#{n}") end |
#position ⇒ Object
62 63 64 |
# File 'app/models/calendar_entry.rb', line 62 def position self.location.display end |
#url ⇒ Object
71 72 73 |
# File 'app/models/calendar_entry.rb', line 71 def url "#{self.start_date.to_formatted_s.urlise}/#{self.id}-#{self.name.urlise}" end |