Class: GeoNamesAPI::Weather

Inherits:
ListEndpoint show all
Defined in:
lib/geonames_api/weather.rb

Constant Summary collapse

METHOD =
"findNearByWeatherJSON"
FIND_PARAMS =
%w(lat lng radius)

Instance Attribute Summary

Attributes inherited from Entity

#request_params

Instance Method Summary collapse

Methods inherited from ListEndpoint

endpoint_returns_list?, #next_page, #to_page

Methods inherited from Base

all, find, where

Methods inherited from Entity

#create_attribute, #initialize, #marshal_dump, #marshal_load, #parse_attr, #parse_response, #set_default_type

Constructor Details

This class inherits a constructor from GeoNamesAPI::Entity

Instance Method Details

#at_localObject



19
20
21
22
# File 'lib/geonames_api/weather.rb', line 19

def at_local
  t = DateTime.parse(datetime)
  time_zone.local(t.year, t.month, t.day, t.hour, t.minute)
end

#at_utcObject



24
25
26
# File 'lib/geonames_api/weather.rb', line 24

def at_utc
  at_local.utc
end

#convert_c_to_f(temp) ⇒ Object



36
37
38
# File 'lib/geonames_api/weather.rb', line 36

def convert_c_to_f(temp)
  temp * 9.to_f / 5.to_f + 32
end

#dew_point_cObject



52
53
54
# File 'lib/geonames_api/weather.rb', line 52

def dew_point_c
  dew_point if temperature
end

#dew_point_fObject



48
49
50
# File 'lib/geonames_api/weather.rb', line 48

def dew_point_f
  convert_c_to_f(dew_point) if temperature
end

#elevation_feetObject



28
29
30
# File 'lib/geonames_api/weather.rb', line 28

def elevation_feet
  elevation * 3.28084 if elevation
end

#elevation_metersObject



32
33
34
# File 'lib/geonames_api/weather.rb', line 32

def elevation_meters
  elevation if elevation
end

#geo_names_api_countryObject



7
8
9
# File 'lib/geonames_api/weather.rb', line 7

def geo_names_api_country
  @geo_names_api_country ||= GeoNamesAPI::Country.find(country_code)
end

#geo_names_api_time_zoneObject



11
12
13
# File 'lib/geonames_api/weather.rb', line 11

def geo_names_api_time_zone
  @geo_names_api_time_zone ||= GeoNamesAPI::TimeZone.find(lat, lng)
end

#temperature_cObject



44
45
46
# File 'lib/geonames_api/weather.rb', line 44

def temperature_c
  temperature if temperature
end

#temperature_fObject



40
41
42
# File 'lib/geonames_api/weather.rb', line 40

def temperature_f
  convert_c_to_f(temperature) if temperature
end

#time_zoneObject



15
16
17
# File 'lib/geonames_api/weather.rb', line 15

def time_zone
  geo_names_api_time_zone.time_zone
end