Class: Event

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/event.rb

Instance Method Summary collapse

Instance Method Details

#attendees_countObject


39
40
41
# File 'app/models/event.rb', line 39

def attendees_count
  self.rsvps.sum(:attendees_count)
end

#attendees_for_user(user) ⇒ Object


35
36
37
# File 'app/models/event.rb', line 35

def attendees_for_user(user)
  self.rsvps.find_by_user_id(user).attendees_count
end

#ownerObject

Used by acts_as_commentable


27
28
29
# File 'app/models/event.rb', line 27

def owner
  self.user
end

#rsvped?(user) ⇒ Boolean


31
32
33
# File 'app/models/event.rb', line 31

def rsvped?(user)
  self.rsvps.find_by_user_id(user)
end

#spans_days?Boolean


51
52
53
# File 'app/models/event.rb', line 51

def spans_days?
  (end_time - start_time) >= 86400
end

#time_and_dateObject


43
44
45
46
47
48
49
# File 'app/models/event.rb', line 43

def time_and_date
  if spans_days?
    string = "#{start_time.strftime("%B %d")} to #{end_time.strftime("%B %d %Y")}"
  else
    string = "#{start_time.strftime("%B %d, %Y")}, #{start_time.strftime("%I:%M %p")} - #{end_time.strftime("%I:%M %p")}"
  end
end