Class: Scrobbler::Venue
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#geo_lat ⇒ Object
Returns the value of attribute geo_lat.
-
#geo_long ⇒ Object
Returns the value of attribute geo_long.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#postalcode ⇒ Object
Returns the value of attribute postalcode.
-
#street ⇒ Object
Returns the value of attribute street.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
-
.id_from_url(url) ⇒ Object
this retrives the venue ID from the venue because the venue ID is not supplied in the XML apart from in the venue URL.
- .new_from_xml(xml) ⇒ Object
- .search(venue, force = false) ⇒ Object
Instance Method Summary collapse
- #events(force = false) ⇒ Object
-
#initialize(name, data = {}) ⇒ Venue
constructor
A new instance of Venue.
- #past_events(force = false) ⇒ Object
Methods inherited from Base
api_key=, connection, get, maybe_streamable_attribute, maybe_streamable_node, post_request, request, sanitize, secret=
Constructor Details
#initialize(name, data = {}) ⇒ Venue
Returns a new instance of Venue.
53 54 55 56 57 |
# File 'lib/scrobbler/venue.rb', line 53 def initialize(name,data = {}) raise ArgumentError if name.blank? @name = name populate_data(data) end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/scrobbler/venue.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/scrobbler/venue.rb', line 3 def country @country end |
#geo_lat ⇒ Object
Returns the value of attribute geo_lat.
4 5 6 |
# File 'lib/scrobbler/venue.rb', line 4 def geo_lat @geo_lat end |
#geo_long ⇒ Object
Returns the value of attribute geo_long.
4 5 6 |
# File 'lib/scrobbler/venue.rb', line 4 def geo_long @geo_long end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/scrobbler/venue.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/scrobbler/venue.rb', line 3 def name @name end |
#postalcode ⇒ Object
Returns the value of attribute postalcode.
3 4 5 |
# File 'lib/scrobbler/venue.rb', line 3 def postalcode @postalcode end |
#street ⇒ Object
Returns the value of attribute street.
3 4 5 |
# File 'lib/scrobbler/venue.rb', line 3 def street @street end |
#timezone ⇒ Object
Returns the value of attribute timezone.
4 5 6 |
# File 'lib/scrobbler/venue.rb', line 4 def timezone @timezone end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/scrobbler/venue.rb', line 4 def url @url end |
Class Method Details
.id_from_url(url) ⇒ Object
this retrives the venue ID from the venue because the venue ID is not supplied in the XML apart from in the venue URL
44 45 46 |
# File 'lib/scrobbler/venue.rb', line 44 def id_from_url(url) url[url.rindex('/')+1,url.length].to_i end |
.new_from_xml(xml) ⇒ Object
7 8 9 10 11 12 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 |
# File 'lib/scrobbler/venue.rb', line 7 def new_from_xml(xml) data = {} xml.children.each do |child| data[:name] = child.content if child.name == 'name' data[:id] = child.content.to_i if child.name == 'id' data[:url] = child.content if child.name == 'url' if child.name == 'location' child.children.each do |location_element| data[:city] = location_element.content if location_element.name == 'city' data[:country] = location_element.content if location_element.name == 'country' data[:street] = location_element.content if location_element.name == 'street' data[:postalcode] = location_element.content if location_element.name == 'postalcode' data[:timezone] = location_element.content if location_element.name == 'timezone' if location_element.name == 'point' || location_element.name == 'geo:point' location_element.children.each do |geo_element| data[:geo_lat] = geo_element.content if ['lat', 'geo:lat'].include?(geo_element.name) data[:geo_long] = geo_element.content if ['long', 'geo:long'].include?(geo_element.name) end end end end end if data.has_key?(:url) && !data.has_key?(:id) data[:id] = id_from_url(data[:url]) end Venue.new(data[:name], data) end |
.search(venue, force = false) ⇒ Object
48 49 50 |
# File 'lib/scrobbler/venue.rb', line 48 def search(venue, force=false) get_response('venue.search', :venuematches, 'venuematches', 'venue', {'venue'=>venue}, force) end |
Instance Method Details
#events(force = false) ⇒ Object
59 60 61 |
# File 'lib/scrobbler/venue.rb', line 59 def events(force=false) get_response('venue.getevents', :events, 'events', 'event', {'venue'=>@id}, force) end |
#past_events(force = false) ⇒ Object
63 64 65 |
# File 'lib/scrobbler/venue.rb', line 63 def past_events(force=false) get_response('venue.getpastevents', :events, 'events', 'event', {'venue'=>@id}, force) end |