Class: X::Place

Inherits:
Resource show all
Defined in:
x-objects/lib/x/objects/place.rb

Overview

A place tagged in a post

The API offers no lookup of places, so a place is read from the response of the post that expanded it, and the class answers no finder. from_id builds one from its identifier, which a place the response did not expand is built as too, and which compares equal to the place it identifies, but hydrate and refresh raise UnsupportedOperation for one that is not hydrated, since there is nothing to look it up with.

Constant Summary collapse

FIELDS =

Every public place field

A minor release may add to it the fields the API adds, so that a lookup asks for them too; see Resource#hydrated? for what that means for a resource looked up with a list of fields of its own.

%w[contained_within country country_code full_name geo id name place_type].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Constructor Details

This class inherits a constructor from X::Resource

Instance Attribute Details

#contained_within ⇒ Array<String> (readonly)

The identifiers of the places containing this place

Examples:

Get the containing places

place.contained_within

Returns:

  • (Array<String>) —

    the containing place identifiers, empty if there are none



97
# File 'x-objects/lib/x/objects/place.rb', line 97

attribute :contained_within, :list

#country ⇒ String? (readonly)

The country name

Examples:

Get the country

place.country

Returns:

  • (String, nil) —

    the country name



73
# File 'x-objects/lib/x/objects/place.rb', line 73

attribute :country

#country_code ⇒ String? (readonly)

The ISO 3166-1 alpha-2 country code

Examples:

Get the country code

place.country_code

Returns:

  • (String, nil) —

    the country code



81
# File 'x-objects/lib/x/objects/place.rb', line 81

attribute :country_code

#full_name ⇒ String? (readonly)

The full name

Examples:

Get the full name

place.full_name

Returns:

  • (String, nil) —

    the full name



65
# File 'x-objects/lib/x/objects/place.rb', line 65

attribute :full_name

#geo ⇒ Hash? (readonly)

The GeoJSON bounding box

Examples:

Get the GeoJSON

place.geo

Returns:

  • (Hash, nil) —

    the GeoJSON



105
# File 'x-objects/lib/x/objects/place.rb', line 105

attribute :geo, :object

#name ⇒ String? (readonly)

The short name

Examples:

Get the name

place.name

Returns:

  • (String, nil) —

    the short name



57
# File 'x-objects/lib/x/objects/place.rb', line 57

attribute :name

#place_type ⇒ String? (readonly)

The place type, such as city or poi

Examples:

Get the place type

place.place_type

Returns:

  • (String, nil) —

    the place type



89
# File 'x-objects/lib/x/objects/place.rb', line 89

attribute :place_type

Class Method Details

.default_params ⇒ Hash{String => Array<String>}

The default query parameters, which request every field

The API offers no lookup of places, so they are requested by the posts that expand them, which ask for these fields, and a place a response included with all of them is hydrated.

Examples:

Get the default parameters

X::Place.default_params # => {"place.fields" => [...]}

Returns:

  • (Hash{String => Array<String>}) —

    the default query parameters



38
# File 'x-objects/lib/x/objects/place.rb', line 38

def self.default_params = {"place.fields" => FIELDS}