Class: Firstfm::Venue
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#images ⇒ Object
Returns the value of attribute images.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phonenumber ⇒ Object
Returns the value of attribute phonenumber.
-
#url ⇒ Object
Returns the value of attribute url.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
- .get_events(venue_id) ⇒ Object
- .init_venue_from_hash(hash) ⇒ Object
- .init_venues_from_hash(hash) ⇒ Object
- .search(venue, page = 1, limit = 50, country = nil) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def id @id end |
#images ⇒ Object
Returns the value of attribute images.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def images @images end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def name @name end |
#phonenumber ⇒ Object
Returns the value of attribute phonenumber.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def phonenumber @phonenumber end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def url @url end |
#website ⇒ Object
Returns the value of attribute website.
5 6 7 |
# File 'lib/firstfm/venue.rb', line 5 def website @website end |
Class Method Details
.get_events(venue_id) ⇒ Object
20 21 22 23 |
# File 'lib/firstfm/venue.rb', line 20 def self.get_events(venue_id) response = get("/2.0/", {:query => {:method => 'venue.getEvents', :venue => venue_id, :api_key => Firstfm.config.api_key, :format => :json}}) events = response['events'] && response['events']['event'] ? Event.init_events_from_hash(response) : [] end |
.init_venue_from_hash(hash) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/firstfm/venue.rb', line 38 def self.init_venue_from_hash(hash) venue = Venue.new venue.id = hash["id"] venue.name = hash["name"] venue.url = hash["url"] venue.location = Location.init_location_from_hash(hash["location"]) venue.website = hash["website"] venue.phonenumber = hash["phonenumber"] venue.images = hash["image"] venue end |
.init_venues_from_hash(hash) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/firstfm/venue.rb', line 29 def self.init_venues_from_hash(hash) return [] unless hash["results"] && hash["results"]["venuematches"] && hash["results"]["venuematches"]["venue"] return [init_venue_from_hash(hash["results"]["venuematches"]["venue"])] if hash["results"]["venuematches"]["venue"].is_a?(Hash) hash["results"]["venuematches"]["venue"].inject([]) do |arr, venue_hash| arr << init_venue_from_hash(venue_hash) arr end end |
.search(venue, page = 1, limit = 50, country = nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/firstfm/venue.rb', line 11 def self.search(venue, page = 1, limit = 50, country = nil) response = get("/2.0/", {:query => {:method => 'venue.search', :venue => venue, :page => page, :limit => limit, :country => country, :api_key => Firstfm.config.api_key, :format => :json}}) venues = response['results'] && response['results']['venuematches'] && response['results']['venuematches']['venue'] ? Venue.init_venues_from_hash(response) : [] collection = WillPaginate::Collection.create(page, limit) do |pager| pager.replace venues pager.total_entries = response['results']['opensearch:totalResults'].to_i end end |
Instance Method Details
#get_events ⇒ Object
25 26 27 |
# File 'lib/firstfm/venue.rb', line 25 def get_events self.class.get_events(self.id) end |