Module: Twitter::REST::PlacesAndGeo

Includes:
Utils
Included in:
API
Defined in:
lib/twitter/rest/places_and_geo.rb

Overview

Methods for working with places and geo data

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#geo_search(options = {}) ⇒ Array<Twitter::Place> Also known as: places_nearby

Searches for places that can be attached to a tweet

Examples:

client.geo_search(query: 'Twitter HQ')

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :lat (Float)

    The latitude to search around.

  • :long (Float)

    The longitude to search around.

  • :query (String)

    Free-form text to match against.

  • :ip (String)

    An IP address for geolocation.

  • :granularity (String) — default: 'neighborhood'

    Minimal granularity of place types to return.

  • :accuracy (String) — default: '0m'

    A hint on the region in which to search.

  • :max_results (Integer)

    A hint as to the number of results to return.

  • :contained_within (String)

    The place_id to restrict results to.

Returns:

Raises:

See Also:



67
68
69
# File 'lib/twitter/rest/places_and_geo.rb', line 67

def geo_search(options = {})
  perform_get_with_object("/1.1/geo/search.json", options, GeoResults)
end

#place(place_id, options = {}) ⇒ Twitter::Place

Returns all the information about a known place

Examples:

client.place('df51dec6f4ee2b2c')

Parameters:

  • place_id (String)

    A place in the world.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

See Also:



23
24
25
# File 'lib/twitter/rest/places_and_geo.rb', line 23

def place(place_id, options = {})
  perform_get_with_object("/1.1/geo/id/#{place_id}.json", options, Place)
end

#reverse_geocode(options = {}) ⇒ Array<Twitter::Place>

Note:

Delivers generalized results about geography.

Searches for up to 20 places that can be used as a place_id

Examples:

client.reverse_geocode(lat: 37.7821, long: -122.4093)

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :lat (Float)

    The latitude to search around.

  • :long (Float)

    The longitude to search around.

  • :accuracy (String) — default: '0m'

    A hint on the region in which to search.

  • :granularity (String) — default: 'neighborhood'

    Minimal granularity of place types to return.

  • :max_results (Integer)

    A hint as to the number of results to return.

Returns:

Raises:

See Also:



44
45
46
# File 'lib/twitter/rest/places_and_geo.rb', line 44

def reverse_geocode(options = {})
  perform_get_with_object("/1.1/geo/reverse_geocode.json", options, GeoResults)
end

#similar_places(options = {}) ⇒ Array<Twitter::Place> Also known as: places_similar

Locates places near the given coordinates which are similar in name

Examples:

client.similar_places(lat: 37.7821, long: -122.4093, name: 'Twitter')

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :lat (Float)

    The latitude to search around.

  • :long (Float)

    The longitude to search around.

  • :name (String)

    The name a place is known as.

  • :contained_within (String)

    The place_id to restrict results to.

Returns:

Raises:

See Also:



90
91
92
# File 'lib/twitter/rest/places_and_geo.rb', line 90

def similar_places(options = {})
  perform_get_with_object("/1.1/geo/similar_places.json", options, GeoResults)
end