Class: Event

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

Instance Method Summary collapse

Instance Method Details

#attendees_countObject



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

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

#attendees_for_user(user) ⇒ Object



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

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

#ownerObject

Used by acts_as_commentable



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

def owner
  self.user
end

#rsvped?(user) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#spans_days?Boolean

Returns:

  • (Boolean)


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

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

#time_and_dateObject



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

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