Class: LastFM::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

from_xml, #initialize, package

Constructor Details

This class inherits a constructor from LastFM::Struct

Instance Attribute Details

#artistsArray<String>



18
19
20
# File 'lib/lastfm/event.rb', line 18

def artists
  @artists
end

#attendanceFixnum



18
19
20
# File 'lib/lastfm/event.rb', line 18

def attendance
  @attendance
end

#cancelledBoolean



18
19
20
# File 'lib/lastfm/event.rb', line 18

def cancelled
  @cancelled
end

#descriptionString



18
19
20
# File 'lib/lastfm/event.rb', line 18

def description
  @description
end

#headlinerString



18
19
20
# File 'lib/lastfm/event.rb', line 18

def headliner
  @headliner
end

#idFixnum



18
19
20
# File 'lib/lastfm/event.rb', line 18

def id
  @id
end

#imagesHash



18
19
20
# File 'lib/lastfm/event.rb', line 18

def images
  @images
end

#reviewsFixnum



18
19
20
# File 'lib/lastfm/event.rb', line 18

def reviews
  @reviews
end

#start_dateTime



18
19
20
# File 'lib/lastfm/event.rb', line 18

def start_date
  @start_date
end

#tagString



18
19
20
# File 'lib/lastfm/event.rb', line 18

def tag
  @tag
end

#tagsArray<String>



18
19
20
# File 'lib/lastfm/event.rb', line 18

def tags
  @tags
end

#titleString



18
19
20
# File 'lib/lastfm/event.rb', line 18

def title
  @title
end

#urlString

Last.fm url for the event



18
19
20
# File 'lib/lastfm/event.rb', line 18

def url
  @url
end

#venueLastFM::Venue



18
19
20
# File 'lib/lastfm/event.rb', line 18

def venue
  @venue
end

#websiteString

Event website (different from Last.fm url)



18
19
20
# File 'lib/lastfm/event.rb', line 18

def website
  @website
end

Instance Method Details

#update_from_node(node) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/lastfm/event.rb', line 20

def update_from_node(node)
  case node.name.to_sym
    when :id
      self.id = node.content.to_i
    when :title
      self.title = node.content
    when :artists # nested artists and headliner

      node.find('*').each{|child| self.update_from_node(child)}
    when :artist
      self.artists ||= []
      self.artists << node.content
    when :headliner
      self.headliner = node.content
    when :venue
      self.venue = LastFM::Venue.from_xml( node )
    when :startDate
      self.start_date = Time.parse(node.content) rescue nil
    when :description
      self.description = node.content
    when :image
      self.images ||= {}
      self.images.merge!({node['size'].to_sym => node.content})
    when :attendance
      self.attendance = node.content.to_i
    when :reviews
      self.reviews = node.content.to_i
    when :tag
      self.tag = node.content
    when :url
      self.url = node.content
    when :website
      self.website = node.content
    when :tickets
      # ???

    when :cancelled
      self.cancelled = (node.content == '1')
    when :tags
      self.tags = node.find('*').each{|tag| tag.content}
  end
end