Module: Placesearch

Defined in:
lib/placesearch.rb,
lib/placesearch/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Placesearch)

    the object that the method was called on



14
15
16
# File 'lib/placesearch.rb', line 14

def self.configure
  yield self
end

.search(query) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/placesearch.rb', line 18

def self.search(query)
	uri = api_url + "query="+CGI::escape(query)+"&sensor=false&key="+api_key
	c = Curl::Easy.new(uri)
	c.timeout = 3
	c.perform

	status = c.response_code
	
	if status==200
	response = JSON.parse(c.body_str)
	else
		response = c.body_str
	end

	OpenStruct.new('status'=>status, 'response'=>response)
end