Class: Twitter::Place

Inherits:
Identity show all
Includes:
Memoizable
Defined in:
lib/twitter/place.rb

Overview

Represents a Twitter place

Instance Attribute Summary collapse

Attributes inherited from Identity

#id

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, display_uri_attr_reader, object_attr_reader, predicate_attr_reader, uri_attr_reader

Methods included from Utils

flat_pmap, pmap

Constructor Details

#initialize(attrs = {}) ⇒ Twitter::Place

Initializes a new place

Examples:

Twitter::Place.new(woeid: 12345)

Parameters:

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

    The attributes hash

Raises:

  • (ArgumentError)

    Error raised when argument is missing a :woeid key



77
78
79
80
# File 'lib/twitter/place.rb', line 77

def initialize(attrs = {})
  attrs[:id] ||= attrs.fetch(:woeid)
  super
end

Instance Attribute Details

#attributesHash (readonly)

The place attributes hash

Examples:

place.attributes

Returns:

  • (Hash)


15
16
17
# File 'lib/twitter/place.rb', line 15

def attributes
  @attributes
end

#countryString (readonly)

The place name

Examples:

place.name

Returns:

  • (String)


37
38
39
# File 'lib/twitter/place.rb', line 37

def country
  @country
end

#full_nameString (readonly)

The place name

Examples:

place.name

Returns:

  • (String)


37
38
39
# File 'lib/twitter/place.rb', line 37

def full_name
  @full_name
end

#nameString (readonly)

The place name

Examples:

place.name

Returns:

  • (String)


37
38
39
# File 'lib/twitter/place.rb', line 37

def name
  @name
end

Instance Method Details

#country_codeString

Returns the country code

Examples:

place.country_code

Returns:

  • (String)


88
89
90
# File 'lib/twitter/place.rb', line 88

def country_code
  @attrs[:country_code] || @attrs[:countryCode]
end

#parent_idInteger

Returns the parent place ID

Examples:

place.parent_id

Returns:

  • (Integer)


99
100
101
# File 'lib/twitter/place.rb', line 99

def parent_id
  @attrs[:parentid]
end

#place_typeString

Returns the place type

Examples:

place.place_type

Returns:

  • (String)


110
111
112
# File 'lib/twitter/place.rb', line 110

def place_type
  @attrs[:place_type] || (@attrs[:placeType] && @attrs[:placeType][:name])
end