forked from sferik/twitter-ruby
/
place.rb
24 lines (20 loc) · 801 Bytes
/
place.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'twitter/base'
require 'twitter/geo_factory'
module Twitter
class Place < Twitter::Base
attr_reader :bounding_box, :country_code, :parent_id, :place_type
lazy_attr_reader :attributes, :country, :full_name, :id, :name, :url,
:woeid
def initialize(attributes={})
attributes = attributes.dup
@bounding_box = Twitter::GeoFactory.new(attributes['bounding_box']) unless attributes['bounding_box'].nil?
@country_code = attributes['country_code'] || attributes['countryCode']
@parent_id = attributes['parentid']
@place_type = attributes['place_type'] || attributes['placeType'] && attributes['placeType']['name']
super(attributes)
end
def ==(other)
super || (other.class == self.class && other.id == self.id)
end
end
end