Class: Dopplr::City
- Inherits:
-
Object
- Object
- Dopplr::City
- Defined in:
- lib/dopplr/city.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#geoname_id ⇒ Object
readonly
Returns the value of attribute geoname_id.
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#localtime ⇒ Object
readonly
Returns the value of attribute localtime.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rgb ⇒ Object
readonly
Returns the value of attribute rgb.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#utc_offset ⇒ Object
readonly
Returns the value of attribute utc_offset.
-
#woeid ⇒ Object
readonly
Returns the value of attribute woeid.
Instance Method Summary collapse
- #add_trip(start, finish) ⇒ Object
-
#initialize(client, id) ⇒ City
constructor
A new instance of City.
- #populate ⇒ Object
Constructor Details
#initialize(client, id) ⇒ City
Returns a new instance of City.
6 7 8 9 10 |
# File 'lib/dopplr/city.rb', line 6 def initialize(client, id) @client = client @geoname_id = id populate end |
Instance Attribute Details
#country ⇒ Object (readonly)
Returns the value of attribute country.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def country @country end |
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def country_code @country_code end |
#geoname_id ⇒ Object (readonly)
Returns the value of attribute geoname_id.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def geoname_id @geoname_id end |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def latitude @latitude end |
#localtime ⇒ Object (readonly)
Returns the value of attribute localtime.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def localtime @localtime end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def longitude @longitude end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def name @name end |
#rgb ⇒ Object (readonly)
Returns the value of attribute rgb.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def rgb @rgb end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
3 4 5 |
# File 'lib/dopplr/city.rb', line 3 def timezone @timezone end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def url @url end |
#utc_offset ⇒ Object (readonly)
Returns the value of attribute utc_offset.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def utc_offset @utc_offset end |
#woeid ⇒ Object (readonly)
Returns the value of attribute woeid.
4 5 6 |
# File 'lib/dopplr/city.rb', line 4 def woeid @woeid end |
Instance Method Details
#add_trip(start, finish) ⇒ Object
27 28 29 |
# File 'lib/dopplr/city.rb', line 27 def add_trip(start, finish) @client.post 'add_trip', :geoname_id => @geoname_id, :start => start, :finish => finish end |
#populate ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dopplr/city.rb', line 12 def populate info = @client.get('city_info', :geoname_id => @geoname_id)['city'] @name = info['name'] @country = info['country'] @timezone = info['timezone'] @latitude = info['latitude'] @longitude = info['longitude'] @country_code = info['country_code'] @woeid = info['woeid'] @rgb = info['rgb'] @utc_offset = info['utcoffset'] @url = info['url'] @localtime = Time.parse info['localtime'].slice(0..-7) end |