Class: LastFM::Event

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

from_xml, inherited, #initialize, package, #to_json

Constructor Details

This class inherits a constructor from LastFM::Struct

Instance Attribute Details

#artistsArray<String>

Returns the current value of artists.

Returns:

  • (Array<String>)

    the current value of artists



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

def artists
  @artists
end

#attendanceFixnum

Returns the current value of attendance.

Returns:

  • (Fixnum)

    the current value of attendance



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

def attendance
  @attendance
end

#cancelledBoolean

Returns the current value of cancelled.

Returns:

  • (Boolean)

    the current value of cancelled



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

def cancelled
  @cancelled
end

#descriptionString

Returns the current value of description.

Returns:

  • (String)

    the current value of description



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

def description
  @description
end

#headlinerString

Returns the current value of headliner.

Returns:

  • (String)

    the current value of headliner



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

def headliner
  @headliner
end

#idFixnum

Returns the current value of id.

Returns:

  • (Fixnum)

    the current value of id



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

def id
  @id
end

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images



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

def images
  @images
end

#reviewsFixnum

Returns the current value of reviews.

Returns:

  • (Fixnum)

    the current value of reviews



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

def reviews
  @reviews
end

#start_dateTime

Returns the current value of start_date.

Returns:

  • (Time)

    the current value of start_date



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

def start_date
  @start_date
end

#tagString

Returns the current value of tag.

Returns:

  • (String)

    the current value of tag



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

def tag
  @tag
end

#tagsArray<String>

Returns the current value of tags.

Returns:

  • (Array<String>)

    the current value of tags



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

def tags
  @tags
end

#titleString

Returns the current value of title.

Returns:

  • (String)

    the current value of title



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

def title
  @title
end

#urlString

Last.fm url for the event

Returns:

  • (String)

    the current value of url



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

def url
  @url
end

#venueLastFM::Venue

Returns the current value of venue.

Returns:



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

def venue
  @venue
end

#websiteString

Event website (different from Last.fm url)

Returns:

  • (String)

    the current value of website



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

def website
  @website
end

Class Method Details

.attend(params) ⇒ Object

Set a user’s attendance status for an event.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

  • :status (Symbol, required)

    attendance status. accepted values are :attending, :maybe_attending, and :not_attending

See Also:



69
70
71
72
73
74
# File 'lib/lastfm/event.rb', line 69

def attend( params )
  LastFM.requires_authentication
  status_codes = { attending: 0, maybe_attending: 1, not_attending: 2 }
  params[:status] = status_codes[params[:status]] if params.include?(:status)
  LastFM.post( "event.attend", params )
end

.get_attendees(params) ⇒ Object

Get a list of attendees for an event.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

See Also:



82
83
84
# File 'lib/lastfm/event.rb', line 82

def get_attendees( params )
  LastFM.get( "event.getAttendees", params )
end

.get_info(params) ⇒ Object

Get the metadata for an event on Last.fm. Includes attendance and lineup information.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

See Also:



90
91
92
# File 'lib/lastfm/event.rb', line 90

def get_info( params )
  LastFM.get( "event.getInfo", params )
end

.get_shouts(params) ⇒ Object

Get shouts for an event.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

  • :page (Fixnum, optional)

    the page number to fetch. defaults to first page

  • :limit (Fixnum, optional)

    the number of results to fetch per page. defaults to 50

See Also:



100
101
102
# File 'lib/lastfm/event.rb', line 100

def get_shouts( params )
  LastFM.get( "event.getShouts", params )
end

.share(params) ⇒ Object

Share an event with one or more Last.fm users or other friends.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

  • :recipient (Array, required)

    a list of email addresses or Last.fm usernames. maximum is 10

  • :message (String, optional)

    an optional message to send. if not supplied a default message will be used

  • :public (Boolean, optional)

    optionally show in the sharing users activity feed. defaults to false

See Also:



111
112
113
114
# File 'lib/lastfm/event.rb', line 111

def share( params )
  LastFM.requires_authentication
  LastFM.post( "event.share", params )
end

.shout(params) ⇒ Object

Shout in an event’s shoutbox.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :event (Fixnum, required)

    numeric last.fm event id

  • :message (String, required)

    message to post to the shoutbox

See Also:



121
122
123
124
# File 'lib/lastfm/event.rb', line 121

def shout( params )
  LastFM.requires_authentication
  LastFM.post( "event.shout", params )
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