Class: Dopplr::City

Inherits:
Object
  • Object
show all
Defined in:
lib/dopplr/city.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countryObject (readonly)

Returns the value of attribute country.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def country
  @country
end

#country_codeObject (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_idObject (readonly)

Returns the value of attribute geoname_id.



4
5
6
# File 'lib/dopplr/city.rb', line 4

def geoname_id
  @geoname_id
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def latitude
  @latitude
end

#localtimeObject (readonly)

Returns the value of attribute localtime.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def localtime
  @localtime
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def name
  @name
end

#rgbObject (readonly)

Returns the value of attribute rgb.



4
5
6
# File 'lib/dopplr/city.rb', line 4

def rgb
  @rgb
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



3
4
5
# File 'lib/dopplr/city.rb', line 3

def timezone
  @timezone
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/dopplr/city.rb', line 4

def url
  @url
end

#utc_offsetObject (readonly)

Returns the value of attribute utc_offset.



4
5
6
# File 'lib/dopplr/city.rb', line 4

def utc_offset
  @utc_offset
end

#woeidObject (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

#populateObject



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