Class: BizRatr::GooglePlacesConnector

Inherits:
Connector
  • Object
show all
Defined in:
lib/bizratr/connector.rb

Instance Method Summary collapse

Methods inherited from Connector

#initialize

Constructor Details

This class inherits a constructor from BizRatr::Connector

Instance Method Details

#make_business(item) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/bizratr/connector.rb', line 93

def make_business(item)
  b = Business.new(@uberclient, item.lat, item.lng, item.name)
  b.add_id(:google_places, item.id)
  b.add_categories(:google_places, item.types)
  b.phone = (item.formatted_phone_number || "").gsub(/[\ ()-]*/, '')
  b.city = item.city || item.vicinity.split(',').last
  b.country = item.country
  b.website = item.website
  b.zip = item.postal_code
  b.address = item.vicinity.split(',').first
  b.add_rating(:google_places, item.rating)
  b.add_review_counts(:google_places, item.reviews.length)
  b
end

#make_client(config) ⇒ Object



84
85
86
# File 'lib/bizratr/connector.rb', line 84

def make_client(config)
  GooglePlaces::Client.new(config[:key])
end

#search_location(location, query) ⇒ Object



88
89
90
91
# File 'lib/bizratr/connector.rb', line 88

def search_location(location, query)
  results = @client.spots(location[0], location[1], :name => query)
  results.map { |item| make_business(item) }
end