Module: Twitter::Client::PlacesAndGeo
- Included in:
- Twitter::Client
- Defined in:
- lib/twitter/client/places_and_geo.rb
Overview
Defines methods related to geography
Instance Method Summary collapse
-
#place(place_id, options = {}) ⇒ Twitter::Place
Returns all the information about a known place.
-
#place_create(options = {}) ⇒ Twitter::Place
Creates a new place at the given latitude and longitude.
-
#places_nearby(options = {}) ⇒ Array<Twitter::Place>
(also: #geo_search)
Search for places that can be attached to a Tweets#update.
-
#places_similar(options = {}) ⇒ Array<Twitter::Place>
Locates places near the given coordinates which are similar in name.
-
#reverse_geocode(options = {}) ⇒ Array<Twitter::Place>
Searches for up to 20 places that can be used as a place_id.
Instance Method Details
#place(place_id, options = {}) ⇒ Twitter::Place
Returns all the information about a known place
86 87 88 89 |
# File 'lib/twitter/client/places_and_geo.rb', line 86 def place(place_id, ={}) place = get("/1/geo/id/#{place_id}.json", ) Twitter::Place.new(place) end |
#place_create(options = {}) ⇒ Twitter::Place
Creates a new place at the given latitude and longitude
106 107 108 109 |
# File 'lib/twitter/client/places_and_geo.rb', line 106 def place_create(={}) place = post("/1/geo/place.json", ) Twitter::Place.new(place) end |
#places_nearby(options = {}) ⇒ Array<Twitter::Place> Also known as: geo_search
Search for places that can be attached to a Tweets#update
27 28 29 30 31 |
# File 'lib/twitter/client/places_and_geo.rb', line 27 def places_nearby(={}) get("/1/geo/search.json", )['result']['places'].map do |place| Twitter::Place.new(place) end end |
#places_similar(options = {}) ⇒ Array<Twitter::Place>
Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to Geo#place to create a new one. The token contained in the response is the token necessary to create a new place.
Locates places near the given coordinates which are similar in name
49 50 51 52 53 |
# File 'lib/twitter/client/places_and_geo.rb', line 49 def places_similar(={}) get("/1/geo/similar_places.json", )['result']['places'].map do |place| Twitter::Place.new(place) end end |
#reverse_geocode(options = {}) ⇒ Array<Twitter::Place>
This request is an informative call and will deliver generalized results about geography.
Searches for up to 20 places that can be used as a place_id
70 71 72 73 74 |
# File 'lib/twitter/client/places_and_geo.rb', line 70 def reverse_geocode(={}) get("/1/geo/reverse_geocode.json", )['result']['places'].map do |place| Twitter::Place.new(place) end end |