module OpenWeather::SeveralCitiesClassMethods
Public Instance Methods
circle_zone(lat, lon, count, options = {})
click to toggle source
Circle zone (lat, lon and count of cities to return) Usage: OpenWeather::Current.circle_zone(55.5, 37.5, 10)
# File lib/open_weather/api.rb, line 44 def circle_zone(lat, lon, count, options = {}) url = 'http://api.openweathermap.org/data/2.5/find' new(options.merge(lat: lat, lon: lon, cnt: count)).retrieve url end
cities(ids, options = {})
click to toggle source
City Ids, an array of integer values. Eg, [2172797, 524901] Usage: OpenWeather::Current.cities([2172797, 524901])
# File lib/open_weather/api.rb, line 25 def cities(ids, options = {}) url = 'http://api.openweathermap.org/data/2.5/group' ids = encode_array ids new(options.merge(id: ids)).retrieve url end
rectangle_zone(top_left_lat, top_left_lon, bottom_right_lat, bottom_right_lon, map_zoom, options = {})
click to toggle source
Bounding box (lat and lon of top left and bottom right points, map zoom) Usage: OpenWeather::Current.rectangle_zone(12, 32, 15, 37, 10)
# File lib/open_weather/api.rb, line 33 def rectangle_zone(top_left_lat, top_left_lon, bottom_right_lat, bottom_right_lon, map_zoom, options = {}) url = 'http://api.openweathermap.org/data/2.5/box/city' bbox = encode_array [top_left_lat, top_left_lon, bottom_right_lat, bottom_right_lon, map_zoom] new(options.merge(bbox: bbox)).retrieve url end
Private Instance Methods
encode_array(arr)
click to toggle source
Encodes an array in the format expected by the API (comma-separated list)
# File lib/open_weather/api.rb, line 51 def encode_array(arr) arr.join ',' end