class FoursquareVenues::Venue

Attributes

json[R]

Public Class Methods

new(foursquare, json) click to toggle source
# File lib/foursquare_venues/venue.rb, line 5
def initialize(foursquare, json)
  @foursquare, @json = foursquare, json
end

Public Instance Methods

all_photos(options={:group => "venue"}) click to toggle source

developer.foursquare.com/docs/venues/photos.html

# File lib/foursquare_venues/venue.rb, line 89
def all_photos(options={:group => "venue"})
  @foursquare.get("#{id}/photos", options)["photos"]["items"].map do |item|
    FoursquareVenues::Photo.new(@foursquare, item)
  end
end
categories() click to toggle source
# File lib/foursquare_venues/venue.rb, line 30
def categories
  @categories ||= @json["categories"].map { |hash| FoursquareVenues::Category.new(hash) }
end
checkins_count() click to toggle source
# File lib/foursquare_venues/venue.rb, line 38
def checkins_count
  @json["stats"]["checkinsCount"]
end
contact() click to toggle source
# File lib/foursquare_venues/venue.rb, line 22
def contact
  @json["contact"]
end
fetch() click to toggle source
# File lib/foursquare_venues/venue.rb, line 9
def fetch
  @json = @foursquare.get("#{id}")["venue"]
  self
end
here_now_count() click to toggle source

count the people who have checked-in at the venue in the last two hours

# File lib/foursquare_venues/venue.rb, line 96
def here_now_count
  fetch unless @json.has_key?("hereNow")
  @json["hereNow"]["count"]
end
icon(size = '') click to toggle source

return the url to the icon of the primary category if no primary is available, then return a default icon optionally accepts a size to return 64px or 256px icon

# File lib/foursquare_venues/venue.rb, line 62
def icon(size = '')
                    icon_url = primary_category ? primary_category.icon : "https://foursquare.com/img/categories/none.png"
                    # return "https://foursquare.com/img/categories/none.png"
                    if ['64','256'].include?(size)
                            icon_url = icon_url.split('.png').first + '_' + size + '.png'
                    end
                    icon_url
end
id() click to toggle source
# File lib/foursquare_venues/venue.rb, line 14
def id
  @json["id"]
end
location() click to toggle source
# File lib/foursquare_venues/venue.rb, line 26
def location
  FoursquareVenues::Location.new(@json["location"])
end
name() click to toggle source
# File lib/foursquare_venues/venue.rb, line 18
def name
  @json["name"]
end
photos() click to toggle source

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

# File lib/foursquare_venues/venue.rb, line 81
def photos
  return all_photos if @json["photos"].blank?
  @json["photos"]["groups"].select { |g| g["type"] == "venue" }.first["items"].map do |item|
    FoursquareVenues::Photo.new(@foursquare, item)
  end
end
photos_count() click to toggle source
# File lib/foursquare_venues/venue.rb, line 75
def photos_count
  @json["photos"]["count"]
end
primary_category() click to toggle source
# File lib/foursquare_venues/venue.rb, line 54
def primary_category
  return nil if categories.blank?
  @primary_category ||= categories.select { |category| category.primary? }.try(:first)
end
short_url() click to toggle source
# File lib/foursquare_venues/venue.rb, line 71
def short_url
  @json["shortUrl"]
end
stats() click to toggle source
# File lib/foursquare_venues/venue.rb, line 50
def stats
  @json["stats"]
end
todos_count() click to toggle source
# File lib/foursquare_venues/venue.rb, line 46
def todos_count
  @json["todos"]["count"]
end
users_count() click to toggle source
# File lib/foursquare_venues/venue.rb, line 42
def users_count
  @json["stats"]["usersCount"]
end
verified?() click to toggle source
# File lib/foursquare_venues/venue.rb, line 34
def verified?
  @json["verified"]
end