Class: Scrobbler::Event
Instance Attribute Summary collapse
-
#artists ⇒ Object
Returns the value of attribute artists.
-
#attendance ⇒ Object
Returns the value of attribute attendance.
-
#description ⇒ Object
Returns the value of attribute description.
-
#headliner ⇒ Object
Returns the value of attribute headliner.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image_large ⇒ Object
Returns the value of attribute image_large.
-
#image_medium ⇒ Object
Returns the value of attribute image_medium.
-
#image_small ⇒ Object
Returns the value of attribute image_small.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#venue ⇒ Object
Returns the value of attribute venue.
Class Method Summary collapse
- .headliner_alrady_listed_in_artist_list?(artists, headliner) ⇒ Boolean
- .new_from_libxml(xml) ⇒ Object
- .update_or_create_from_xml(xml, event = nil) ⇒ Object
Instance Method Summary collapse
- #attend(session, attendance_status) ⇒ Object
- #attendees(force = false) ⇒ Object
-
#initialize(id, input = {}) ⇒ Event
constructor
A new instance of Event.
-
#load_info ⇒ Object
Load additional informatalbumion about this event.
- #share ⇒ Object
- #shout ⇒ Object
- #shouts(force = false) ⇒ Object
Methods included from ImageClassFuncs
Methods included from ImageObjectFuncs
Methods inherited from Base
api_key=, connection, get, maybe_streamable_attribute, maybe_streamable_node, post_request, request, sanitize, secret=
Constructor Details
#initialize(id, input = {}) ⇒ Event
Returns a new instance of Event.
66 67 68 69 70 71 |
# File 'lib/scrobbler/event.rb', line 66 def initialize(id,input={}) raise ArgumentError if id.blank? @id = id populate_data(input) load_info() if input[:include_info] end |
Instance Attribute Details
#artists ⇒ Object
Returns the value of attribute artists.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def artists @artists end |
#attendance ⇒ Object
Returns the value of attribute attendance.
9 10 11 |
# File 'lib/scrobbler/event.rb', line 9 def attendance @attendance end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/scrobbler/event.rb', line 7 def description @description end |
#headliner ⇒ Object
Returns the value of attribute headliner.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def headliner @headliner end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/scrobbler/event.rb', line 7 def id @id end |
#image_large ⇒ Object
Returns the value of attribute image_large.
9 10 11 |
# File 'lib/scrobbler/event.rb', line 9 def image_large @image_large end |
#image_medium ⇒ Object
Returns the value of attribute image_medium.
9 10 11 |
# File 'lib/scrobbler/event.rb', line 9 def image_medium @image_medium end |
#image_small ⇒ Object
Returns the value of attribute image_small.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def image_small @image_small end |
#reviews ⇒ Object
Returns the value of attribute reviews.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def reviews @reviews end |
#start_date ⇒ Object
Returns the value of attribute start_date.
7 8 9 |
# File 'lib/scrobbler/event.rb', line 7 def start_date @start_date end |
#start_time ⇒ Object
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/scrobbler/event.rb', line 7 def start_time @start_time end |
#tag ⇒ Object
Returns the value of attribute tag.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def tag @tag end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/scrobbler/event.rb', line 7 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/scrobbler/event.rb', line 8 def url @url end |
#venue ⇒ Object
Returns the value of attribute venue.
9 10 11 |
# File 'lib/scrobbler/event.rb', line 9 def venue @venue end |
Class Method Details
.headliner_alrady_listed_in_artist_list?(artists, headliner) ⇒ Boolean
54 55 56 57 58 59 |
# File 'lib/scrobbler/event.rb', line 54 def headliner_alrady_listed_in_artist_list?(artists,headliner) artists.each do |artist| return true if artist.name == headliner.name end false end |
.new_from_libxml(xml) ⇒ Object
61 62 63 |
# File 'lib/scrobbler/event.rb', line 61 def new_from_libxml(xml) update_or_create_from_xml(xml) end |
.update_or_create_from_xml(xml, event = nil) ⇒ Object
13 14 15 16 17 18 19 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 |
# File 'lib/scrobbler/event.rb', line 13 def update_or_create_from_xml(xml, event=nil) data = {} artists = [] headliner = nil venue = nil xml.children.each do |child| data[:id] = child.content.to_i if child.name == 'id' data[:title] = child.content if child.name == 'title' if child.name == 'artists' child.children.each do |artist_element| artists << Artist.new(artist_element.content) if artist_element.name == 'artist' headliner = Artist.new(artist_element.content) if artist_element.name == 'headliner' end artists << headliner unless headliner.nil? || headliner_alrady_listed_in_artist_list?(artists,headliner) end maybe_image_node(data, child) data[:url] = child.content if child.name == 'url' data[:description] = child.content if child.name == 'description' data[:attendance] = child.content.to_i if child.name == 'attendance' data[:reviews] = child.content.to_i if child.name == 'reviews' data[:tag] = child.content if child.name == 'tag' data[:start_date] = Time.parse(child.content) if child.name == 'startDate' data[:start_time] = child.content if child.name == 'startTime' venue = Venue.new_from_xml(child) if child.name == 'venue' end if event.nil? event = Event.new(data[:id],data) else event.send :populate_data, data end event.artists = artists.uniq event.headliner = headliner event.venue = venue event end |
Instance Method Details
#attend(session, attendance_status) ⇒ Object
86 87 88 |
# File 'lib/scrobbler/event.rb', line 86 def attend(session, attendance_status) doc = Base.post_request('event.attend',{:event => @id, :signed => true, :status => attendance_status, :sk => session.key}) end |
#attendees(force = false) ⇒ Object
77 78 79 |
# File 'lib/scrobbler/event.rb', line 77 def attendees(force = false) get_response('event.getattendees', :attendees, 'attendees', 'user', {'event'=>@id}, force) end |
#load_info ⇒ Object
Load additional informatalbumion about this event
Calls “event.getinfo” REST method
98 99 100 101 102 103 |
# File 'lib/scrobbler/event.rb', line 98 def load_info doc = Base.request('event.getinfo', {'event' => @id}) doc.root.children.each do |child| Event.update_or_create_from_xml(child, self) if child.name == 'event' end end |
#share ⇒ Object
90 91 92 93 |
# File 'lib/scrobbler/event.rb', line 90 def share # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
#shout ⇒ Object
81 82 83 84 |
# File 'lib/scrobbler/event.rb', line 81 def shout # This function require authentication, but SimpleAuth is not yet 2.0 raise NotImplementedError end |
#shouts(force = false) ⇒ Object
73 74 75 |
# File 'lib/scrobbler/event.rb', line 73 def shouts(force = false) get_response('event.getshouts', :shouts, 'shouts', 'shout', {'event'=>@id}, force) end |