Class: GeoNamesAPI::TimeZone
Constant Summary
collapse
- METHOD =
"timezoneJSON"
- FIND_PARAMS =
%w(lat lng radius date)
Instance Attribute Summary
Attributes inherited from Entity
#request_params
Instance Method Summary
collapse
endpoint_returns_list?
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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/geonames_api/time_zone.rb', line 24
def method_missing(method, *args)
case method
when /\A(.*)_(local|utc)\Z/
send($2, $1)
end
end
|
Instance Method Details
#common_name ⇒ Object
11
12
13
|
# File 'lib/geonames_api/time_zone.rb', line 11
def common_name
ActiveSupport::TimeZone::MAPPING.key(timezone_id)
end
|
#local(time_type) ⇒ Object
15
16
17
18
|
# File 'lib/geonames_api/time_zone.rb', line 15
def local(time_type)
t = DateTime.parse(send(time_type))
time_zone.local(t.year, t.month, t.day, t.hour, t.minute)
end
|
#time_zone ⇒ Object
7
8
9
|
# File 'lib/geonames_api/time_zone.rb', line 7
def time_zone
ActiveSupport::TimeZone.new(timezone_id)
end
|
#utc(time_type) ⇒ Object
20
21
22
|
# File 'lib/geonames_api/time_zone.rb', line 20
def utc(time_type)
local(time_type).utc
end
|