Sha256: 86dfbfe03d591657df66bb2f4c07e4fd480ac69ac91c65d92e3f81906f58d00b

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'equalizer'
require 'twitter/identity'

module Twitter
  class Place < Twitter::Identity
    attr_reader :attributes, :country, :full_name, :name
    alias_method :woe_id, :id
    alias_method :woeid, :id
    object_attr_reader :GeoFactory, :bounding_box
    object_attr_reader :Place, :contained_within
    alias_method :contained?, :contained_within?
    uri_attr_reader :uri

    # Initializes a new place
    #
    # @param attrs [Hash]
    # @raise [ArgumentError] Error raised when supplied argument is missing a :woeid key.
    # @return [Twitter::Place]
    def initialize(attrs = {})
      attrs[:id] ||= attrs[:woeid]
      super
    end

    # @return [String]
    def country_code
      @attrs[:country_code] || @attrs[:countryCode] # rubocop:disable SymbolName
    end
    memoize :country_code

    # @return [Integer]
    def parent_id
      @attrs[:parentid]
    end
    memoize :parent_id

    # @return [String]
    def place_type
      @attrs[:place_type] || @attrs[:placeType] && @attrs[:placeType][:name] # rubocop:disable SymbolName
    end
    memoize :place_type
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter-5.10.0 lib/twitter/place.rb