Class: Foursquare::Venue
- Inherits:
-
Object
- Object
- Foursquare::Venue
- Defined in:
- lib/foursquare/venue.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
- #all_photos(options = {:group => "venue"}) ⇒ Object
- #categories ⇒ Object
- #checkins_count ⇒ Object
- #contact ⇒ Object
- #fetch ⇒ Object
-
#here_now_checkins(options = {:limit => "50"}) ⇒ Object
returns a list of checkins (only if a valid oauth token from a user is provided) developer.foursquare.com/docs/venues/herenow.html options: limit, offset, aftertimestamp.
-
#here_now_count ⇒ Object
count the people who have checked-in at the venue in the last two hours.
-
#icon ⇒ Object
return the url to the icon of the primary category if no primary is available, then return a default icon.
- #id ⇒ Object
-
#initialize(foursquare, json) ⇒ Venue
constructor
A new instance of Venue.
- #location ⇒ Object
- #name ⇒ Object
-
#photos ⇒ Object
not all photos may be present here (but we try to avoid one extra API call) if you want to get all the photos, try all_photos.
- #photos_count ⇒ Object
- #primary_category ⇒ Object
- #short_url ⇒ Object
- #stats ⇒ Object
- #todos_count ⇒ Object
- #users_count ⇒ Object
- #verified? ⇒ Boolean
Constructor Details
#initialize(foursquare, json) ⇒ Venue
Returns a new instance of Venue.
5 6 7 |
# File 'lib/foursquare/venue.rb', line 5 def initialize(foursquare, json) @foursquare, @json = foursquare, json end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
3 4 5 |
# File 'lib/foursquare/venue.rb', line 3 def json @json end |
Instance Method Details
#all_photos(options = {:group => "venue"}) ⇒ Object
83 84 85 86 87 |
# File 'lib/foursquare/venue.rb', line 83 def all_photos(={:group => "venue"}) @foursquare.get("venues/#{id}/photos", )["photos"]["items"].map do |item| Foursquare::Photo.new(@foursquare, item) end end |
#categories ⇒ Object
30 31 32 |
# File 'lib/foursquare/venue.rb', line 30 def categories @categories ||= @json["categories"].map { |hash| Foursquare::Category.new(hash) } end |
#checkins_count ⇒ Object
38 39 40 |
# File 'lib/foursquare/venue.rb', line 38 def checkins_count @json["stats"]["checkinsCount"] end |
#contact ⇒ Object
22 23 24 |
# File 'lib/foursquare/venue.rb', line 22 def contact @json["contact"] end |
#fetch ⇒ Object
9 10 11 12 |
# File 'lib/foursquare/venue.rb', line 9 def fetch @json = @foursquare.get("venues/#{id}")["venue"] self end |
#here_now_checkins(options = {:limit => "50"}) ⇒ Object
returns a list of checkins (only if a valid oauth token from a user is provided) developer.foursquare.com/docs/venues/herenow.html options: limit, offset, aftertimestamp
98 99 100 101 102 |
# File 'lib/foursquare/venue.rb', line 98 def here_now_checkins(={:limit => "50"}) @foursquare.get("venues/#{id}/herenow", )["hereNow"]["items"].map do |item| Foursquare::Checkin.new(@foursquare, item) end end |
#here_now_count ⇒ Object
count the people who have checked-in at the venue in the last two hours
90 91 92 93 |
# File 'lib/foursquare/venue.rb', line 90 def here_now_count fetch unless @json.has_key?("hereNow") @json["hereNow"]["count"] end |
#icon ⇒ Object
return the url to the icon of the primary category if no primary is available, then return a default icon
61 62 63 |
# File 'lib/foursquare/venue.rb', line 61 def icon primary_category ? primary_category["icon"] : "https://foursquare.com/img/categories/none.png" end |
#id ⇒ Object
14 15 16 |
# File 'lib/foursquare/venue.rb', line 14 def id @json["id"] end |
#location ⇒ Object
26 27 28 |
# File 'lib/foursquare/venue.rb', line 26 def location Foursquare::Location.new(@json["location"]) end |
#name ⇒ Object
18 19 20 |
# File 'lib/foursquare/venue.rb', line 18 def name @json["name"] end |
#photos ⇒ Object
not all photos may be present here (but we try to avoid one extra API call) if you want to get all the photos, try all_photos
75 76 77 78 79 80 |
# File 'lib/foursquare/venue.rb', line 75 def photos return all_photos if @json["photos"].blank? @json["photos"]["groups"].select { |g| g["type"] == "venue" }.first["items"].map do |item| Foursquare::Photo.new(@foursquare, item) end end |
#photos_count ⇒ Object
69 70 71 |
# File 'lib/foursquare/venue.rb', line 69 def photos_count @json["photos"]["count"] end |
#primary_category ⇒ Object
54 55 56 57 |
# File 'lib/foursquare/venue.rb', line 54 def primary_category return nil if categories.blank? @primary_category ||= categories.select { |category| category.primary? }.try(:first) end |
#short_url ⇒ Object
65 66 67 |
# File 'lib/foursquare/venue.rb', line 65 def short_url @json["shortUrl"] end |
#stats ⇒ Object
50 51 52 |
# File 'lib/foursquare/venue.rb', line 50 def stats @json["stats"] end |
#todos_count ⇒ Object
46 47 48 |
# File 'lib/foursquare/venue.rb', line 46 def todos_count @json["todos"]["count"] end |
#users_count ⇒ Object
42 43 44 |
# File 'lib/foursquare/venue.rb', line 42 def users_count @json["stats"]["usersCount"] end |
#verified? ⇒ Boolean
34 35 36 |
# File 'lib/foursquare/venue.rb', line 34 def verified? @json["verified"] end |