Sha256: f7dbdf7540cc8cedc23c4f80740a19f5671a86e097bd98d7ece088ca15f545a5
Contents?: true
Size: 890 Bytes
Versions: 1
Compression:
Stored size: 890 Bytes
Contents
class Spud::SpudCalendarEventModel < ActiveRecord::Base self.table_name = 'spud_calendar_events' belongs_to :spud_calendar validates_presence_of :title, :start_at, :end_at, :spud_calendar_id scope :ordered, ->{ order('start_at desc') } scope :upcoming, ->(limit=false){ where('start_at >= ?', Date.today).order('start_at asc').limit(limit) } scope :in_month_of, ->(date){ first = date.beginning_of_month range_start = Time.zone.local(first.year, first.month, first.day) range_end = range_start.end_of_month where(:start_at => range_start..range_end) } def start_date return start_at.to_date end def days_span return (end_at.to_date - start_at.to_date).to_i + 1 end def falls_on?(day) start_date = start_at.beginning_of_day.to_date end_date = end_at.end_of_day.to_date return day >= start_date && day <= end_date end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tb_events-1.1.2 | app/models/spud/spud_calendar_event_model.rb |