Class: EventDb::Model::Event
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- EventDb::Model::Event
- Defined in:
- lib/eventdb/models.rb
Instance Method Summary collapse
-
#date_str ⇒ Object
date pretty printed (pre-formatted) as string.
-
#live ⇒ Object
rename to now_on/on_now/now_playing/running/etc.
-
#upcoming ⇒ Object
todo: auto-add today ?? - why, why not? move order(‘start_date’) into its own scope ??.
Instance Method Details
#date_str ⇒ Object
date pretty printed (pre-formatted) as string
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/eventdb/models.rb', line 17 def date_str # date pretty printed (pre-formatted) as string ## note: wday - (0-6, Sunday is zero). if days == 1 buf = '' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << ' ' buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s elsif days == 2 buf = '' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << '+' buf << Date::ABBR_DAYNAMES[end_date.wday] buf << ' ' buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s buf << '+' if start_date.month != end_date.month buf << Date::ABBR_MONTHNAMES[end_date.month] buf << '/' end buf << end_date.day.to_s else ## assume multi day buf = '' buf << Date::ABBR_DAYNAMES[start_date.wday] buf << '-' buf << Date::ABBR_DAYNAMES[end_date.wday] buf << ' ' buf << Date::ABBR_MONTHNAMES[start_date.month] buf << '/' buf << start_date.day.to_s buf << '-' if start_date.month != end_date.month buf << Date::ABBR_MONTHNAMES[end_date.month] buf << '/' end buf << end_date.day.to_s end buf end |
#live ⇒ Object
rename to now_on/on_now/now_playing/running/etc. - why? why not??
14 |
# File 'lib/eventdb/models.rb', line 14 scope :live, ->(today) { order('start_date').where( 'start_date <= ? AND end_date >= ?', today, today ) } |
#upcoming ⇒ Object
todo: auto-add today ?? - why, why not?
move order('start_date') into its own scope ??
11 |
# File 'lib/eventdb/models.rb', line 11 scope :upcoming, ->(today) { order('start_date').where( 'start_date > ?', today ) } |