Class: GeoNamesAPI::Weather
Constant Summary
collapse
- METHOD =
"findNearByWeatherJSON"
- FIND_PARAMS =
%w(lat lng radius)
Instance Attribute Summary
Attributes inherited from Entity
#request_params
Instance Method Summary
collapse
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
Instance Method Details
#at_local ⇒ Object
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_utc ⇒ Object
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_c ⇒ Object
52
53
54
|
# File 'lib/geonames_api/weather.rb', line 52
def dew_point_c
dew_point if temperature
end
|
#dew_point_f ⇒ Object
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_feet ⇒ Object
28
29
30
|
# File 'lib/geonames_api/weather.rb', line 28
def elevation_feet
elevation * 3.28084 if elevation
end
|
#elevation_meters ⇒ Object
32
33
34
|
# File 'lib/geonames_api/weather.rb', line 32
def elevation_meters
elevation if elevation
end
|
#geo_names_api_country ⇒ Object
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_zone ⇒ Object
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_c ⇒ Object
44
45
46
|
# File 'lib/geonames_api/weather.rb', line 44
def temperature_c
temperature if temperature
end
|
#temperature_f ⇒ Object
40
41
42
|
# File 'lib/geonames_api/weather.rb', line 40
def temperature_f
convert_c_to_f(temperature) if temperature
end
|
#time_zone ⇒ Object
15
16
17
|
# File 'lib/geonames_api/weather.rb', line 15
def time_zone
geo_names_api_time_zone.time_zone
end
|