Class: FestivityEventList::FestivityEvent

Inherits:
Object
  • Object
show all
Includes:
Festivity::Admin::AssetsHelper
Defined in:
app/models/festivity_event_list/festivity_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Festivity::Admin::AssetsHelper

#image_url, #image_url_from_all_assets

Constructor Details

#initialize(event_id, performances) ⇒ FestivityEvent

Returns a new instance of FestivityEvent.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/festivity_event_list/festivity_event.rb', line 7

def initialize(event_id, performances)
  @id = event_id
  @performances = performances
  @title = performances.first.event_title
  @short_description = performances.first.short_description
  @header = performances.first.header
  @sub_header = performances.first.sub_header
  @featured_item = performances.first.featured_item
  @buy_url = performances.first.buy_url

  @locations = self.performances.
      map{ |performance| FestivityEventList::FestivityLocation.new ({
      id: performance.location_id,
      slug: performance.location_slug,
      title: performance.location_title,
      directions_url: performance.festivity_directions_url,
      area_id: performance.area_id,
      area_slug: performance.area_slug,
      area_title: performance.area_title}) }.
      uniq{ |location| location.id }

  @categories = performances.first.festivity_categories

  @assets = performances.first.assets

end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def assets
  @assets
end

#buy_urlObject (readonly)

Returns the value of attribute buy_url.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def buy_url
  @buy_url
end

#categoriesObject (readonly)

Returns the value of attribute categories.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def categories
  @categories
end

Returns the value of attribute featured_item.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def featured_item
  @featured_item
end

#headerObject (readonly)

Returns the value of attribute header.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def header
  @header
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def id
  @id
end

#locationsObject (readonly)

Returns the value of attribute locations.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def locations
  @locations
end

#performancesObject (readonly)

Returns the value of attribute performances.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def performances
  @performances
end

#short_descriptionObject (readonly)

Returns the value of attribute short_description.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def short_description
  @short_description
end

#sub_headerObject (readonly)

Returns the value of attribute sub_header.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def sub_header
  @sub_header
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'app/models/festivity_event_list/festivity_event.rb', line 4

def title
  @title
end

Instance Method Details

#imageObject



34
35
36
37
# File 'app/models/festivity_event_list/festivity_event.rb', line 34

def image
  image = assets.select { |asset| asset.title == "featured_image" }.first if assets.size > 0
  image.thumbnail(:normal) unless image.nil?
end