Class: Songkicky::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Event

Returns a new instance of Event.



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

def initialize(hash)
  @id   = hash['id']
  @type = hash['type']

  @festival = Festival.new(hash['series']) if @type.downcase == 'festival'

  @name = hash['displayName']

  @popularity = hash['popularity']

  @date = Date.strptime(hash['start']['date'], '%Y-%m-%d')

  @lat  = hash['location']['lat']
  @lng  = hash['location']['lng']
  @venue = Venue.new(hash['venue'])
  @metro_area = MetroArea.new(hash['venue']['metroArea'])

  headlines = hash['performance'].select {|p| p['billing'] == 'headline'}
  @headliners = headlines.map {|p| Artist.find_by_name(p['artist']['displayName'])}
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



7
8
9
# File 'lib/event.rb', line 7

def date
  @date
end

#festivalObject

Returns the value of attribute festival.



7
8
9
# File 'lib/event.rb', line 7

def festival
  @festival
end

#headlinersObject

Returns the value of attribute headliners.



7
8
9
# File 'lib/event.rb', line 7

def headliners
  @headliners
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/event.rb', line 7

def id
  @id
end

#latObject

Returns the value of attribute lat.



7
8
9
# File 'lib/event.rb', line 7

def lat
  @lat
end

#lngObject

Returns the value of attribute lng.



7
8
9
# File 'lib/event.rb', line 7

def lng
  @lng
end

#metro_areaObject

Returns the value of attribute metro_area.



7
8
9
# File 'lib/event.rb', line 7

def metro_area
  @metro_area
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/event.rb', line 7

def name
  @name
end

#popularityObject

Returns the value of attribute popularity.



7
8
9
# File 'lib/event.rb', line 7

def popularity
  @popularity
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/event.rb', line 7

def type
  @type
end

#venueObject

Returns the value of attribute venue.



7
8
9
# File 'lib/event.rb', line 7

def venue
  @venue
end