Class: Bandsintown::Venue
Instance Attribute Summary collapse
-
#address ⇒ Object
Note - address and postalcode are not returned in API responses, but they are accepted when passing venue data to Bandsintown::Event.create.
-
#bandsintown_id ⇒ Object
Returns the value of attribute bandsintown_id.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#events ⇒ Object
Returns an array of Bandsintown::Event objects for each of the venues’s upcoming events available through bandsintown.com.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#name ⇒ Object
Returns the value of attribute name.
-
#postalcode ⇒ Object
Note - address and postalcode are not returned in API responses, but they are accepted when passing venue data to Bandsintown::Event.create.
-
#region ⇒ Object
Returns the value of attribute region.
Attributes inherited from Base
Class Method Summary collapse
- .build_from_json(args = {}) ⇒ Object
- .resource_path ⇒ Object
-
.search(options = {}) ⇒ Object
Returns an array of Bandsintown::Venue objects matching the options passed.
Instance Method Summary collapse
-
#initialize(bandsintown_id) ⇒ Venue
constructor
A new instance of Venue.
Methods inherited from Base
check_for_errors, connection, parse, request, request_and_parse, #to_hash
Constructor Details
#initialize(bandsintown_id) ⇒ Venue
Returns a new instance of Venue.
8 9 10 |
# File 'lib/bandsintown/venue.rb', line 8 def initialize(bandsintown_id) @bandsintown_id = bandsintown_id end |
Instance Attribute Details
#address ⇒ Object
Note - address and postalcode are not returned in API responses, but they are accepted when passing venue data to Bandsintown::Event.create.
6 7 8 |
# File 'lib/bandsintown/venue.rb', line 6 def address @address end |
#bandsintown_id ⇒ Object
Returns the value of attribute bandsintown_id.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def bandsintown_id @bandsintown_id end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def country @country end |
#events ⇒ Object
Returns an array of Bandsintown::Event objects for each of the venues’s upcoming events available through bandsintown.com. See www.bandsintown.com/api/requests#venues-events for more information.
example:
# using Paradise Rock Club in Boston, MA (bandsintown id 1700)
venue = Bandsintown::Venue.new(1700)
upcoming_paradise_events = venue.events
21 22 23 |
# File 'lib/bandsintown/venue.rb', line 21 def events @events end |
#latitude ⇒ Object
Returns the value of attribute latitude.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def longitude @longitude end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def name @name end |
#postalcode ⇒ Object
Note - address and postalcode are not returned in API responses, but they are accepted when passing venue data to Bandsintown::Event.create.
6 7 8 |
# File 'lib/bandsintown/venue.rb', line 6 def postalcode @postalcode end |
#region ⇒ Object
Returns the value of attribute region.
3 4 5 |
# File 'lib/bandsintown/venue.rb', line 3 def region @region end |
Class Method Details
.build_from_json(args = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bandsintown/venue.rb', line 60 def self.build_from_json(args={}) returning Bandsintown::Venue.new(args['id']) do |v| v.name = args["name"] v.bandsintown_url = args["url"] v.bandsintown_id = args["id"] v.region = args["region"] v.city = args["city"] v.country = args["country"] v.latitude = args["latitude"] v.longitude = args["longitude"] end end |
.resource_path ⇒ Object
56 57 58 |
# File 'lib/bandsintown/venue.rb', line 56 def self.resource_path "venues" end |
.search(options = {}) ⇒ Object
Returns an array of Bandsintown::Venue objects matching the options passed. See www.bandsintown.com/api/requests#venues-search for more information.
options:
:query - a string to match the beginning of venue names :location - a string with one of the following formats:
* 'city, state' for United States and Canada
* 'city, country' for other countries
* 'latitude,longitude'
* ip address - will use the location of the passed ip address
* 'use_geoip' - will use the location of the ip address that made the request
:radius - a number in miles. API default is 25, maximum is 150. :per_page - number of results per response. Default is 5, maximum is 100. :page - offset for paginated results. API default is 1.
notes:
:query is required for this request, all other arguments are optional.
examples:
All venues (first page w/ 5 results) with name beginning with ‘House of Blues’:
Bandsintown::Venue.search(:query => 'House of Blues')
All venues (first page w/ 5 results) with name beginning with ‘House of’ within 25 miles of San Diego, CA:
Bandsintown::Venue.search(:query => "House of", :location => "San Diego, CA")
Second page of all venues near the request’s ip address with name beginning with “Club” and 100 results per page:
Bandsintown::Venue.search(:query => "Club", :per_page => 100, :page => 2, :location => "use_geoip")
52 53 54 |
# File 'lib/bandsintown/venue.rb', line 52 def self.search( = {}) self.request_and_parse(:get, "search", ).map { |venue_hash| Bandsintown::Venue.build_from_json(venue_hash) } end |