Class: Firstfm::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/firstfm/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#artistsObject

Returns the value of attribute artists.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def artists
  @artists
end

#attendanceObject

Returns the value of attribute attendance.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def attendance
  @attendance
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def description
  @description
end

#headlinerObject

Returns the value of attribute headliner.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def headliner
  @headliner
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def id
  @id
end

#imagesObject

Returns the value of attribute images.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def images
  @images
end

#reviewsObject

Returns the value of attribute reviews.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def reviews
  @reviews
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def start_date
  @start_date
end

#tagObject

Returns the value of attribute tag.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def tag
  @tag
end

#tagsObject

Returns the value of attribute tags.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def title
  @title
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def url
  @url
end

#venueObject

Returns the value of attribute venue.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def venue
  @venue
end

#websiteObject

Returns the value of attribute website.



5
6
7
# File 'lib/firstfm/event.rb', line 5

def website
  @website
end

Class Method Details

.init_event_from_hash(hash) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/firstfm/event.rb', line 17

def self.init_event_from_hash(hash)
  return nil unless hash.is_a?(Hash)
  event = Event.new
  event.id = hash["id"]
  event.title = hash["title"]
  event.url = hash["url"]
  event.tag = hash["tag"]
  event.venue = Venue.init_venue_from_hash(hash["venue"])
  event.description = hash["description"]
  event.attendance = hash["attendance"]
  event.reviews = hash["reviews"]
  event.website = hash["website"]
  event.start_date = hash['startDate']
  event.artists = hash['artists']['artist'] if hash['artists']
  event.headliner = hash['artists']['headliner'] if hash['artists']
  event.tags = hash["tags"]["tag"] if hash["tags"]
  event.images = hash["image"]
  event
end

.init_events_from_hash(hash) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/firstfm/event.rb', line 7

def self.init_events_from_hash(hash)
  return [] unless hash["events"] && hash["events"]["event"]
  return [init_event_from_hash(hash["events"]["event"])] if hash["events"]["event"].is_a?(Hash)
  
  hash["events"]["event"].inject([]) do |arr, venue_hash|
    arr << init_event_from_hash(venue_hash)
    arr
  end
end