Module: OpenWeather::Endpoints::Current
- Included in:
- Client
- Defined in:
- lib/open_weather/endpoints/current.rb
Instance Method Summary collapse
- #current_cities_geo_box(*args) ⇒ Object
- #current_cities_geo_circle(*args) ⇒ Object
- #current_cities_id(*args) ⇒ Object
- #current_city(name, state = nil, country = nil, options = {}) ⇒ Object
- #current_city_id(id, options = {}) ⇒ Object
- #current_geo(lat, lon = nil, options = {}) ⇒ Object
- #current_weather(options = {}) ⇒ Object
- #current_zip(code, country = nil, options = {}) ⇒ Object
Instance Method Details
#current_cities_geo_box(*args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/open_weather/endpoints/current.rb', line 44 def current_cities_geo_box(*args) = args[-1].is_a?(Hash) ? args.pop.dup : {} [:bbox] = args.join(',') if args.any? [:bbox] ||= [ .delete(:lon_left), .delete(:lat_bottom), .delete(:lon_right), .delete(:lat_top), .delete(:zoom) ].join(',') OpenWeather::Models::List.new(get('2.5/box/city', ), ) end |
#current_cities_geo_circle(*args) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/open_weather/endpoints/current.rb', line 57 def current_cities_geo_circle(*args) = args[-1].is_a?(Hash) ? args.pop.dup : {} if args.any? [:lat] = args.shift [:lon] = args.shift [:cnt] = args.shift || 1 end OpenWeather::Models::List.new(get('2.5/find', ), ) end |
#current_cities_id(*args) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/open_weather/endpoints/current.rb', line 69 def current_cities_id(*args) = args[-1].is_a?(Hash) ? args.pop.dup : {} [:id] = args.join(',') if args.any? [:id] = .delete(:ids) if .key?(:ids) [:id] = [:id].join(',') if [:id].is_a?(Array) OpenWeather::Models::List.new(get('2.5/group', ), ) end |
#current_city(name, state = nil, country = nil, options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/open_weather/endpoints/current.rb', line 16 def current_city(name, state = nil, country = nil, = {}) = name.is_a?(Hash) ? .merge(name) : .merge(city: name, state: state, country: country) current_weather() end |
#current_city_id(id, options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/open_weather/endpoints/current.rb', line 21 def current_city_id(id, = {}) = id.is_a?(Hash) ? .merge(id) : .merge(id: id) current_weather() end |
#current_geo(lat, lon = nil, options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/open_weather/endpoints/current.rb', line 11 def current_geo(lat, lon = nil, = {}) = lat.is_a?(Hash) ? .merge(lat) : .merge(lat: lat, lon: lon) current_weather() end |
#current_weather(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/open_weather/endpoints/current.rb', line 26 def current_weather( = {}) if .key?(:zip) && .key?(:country) = .dup [:zip] = [ .delete(:zip), .delete(:country) ].compact.join(',') elsif .key?(:city) = .dup [:q] = [ .delete(:city), .delete(:state), .delete(:country) ].compact.join(',') end OpenWeather::Models::City::Weather.new(get('2.5/weather', ), ) end |
#current_zip(code, country = nil, options = {}) ⇒ Object
6 7 8 9 |
# File 'lib/open_weather/endpoints/current.rb', line 6 def current_zip(code, country = nil, = {}) = code.is_a?(Hash) ? .merge(code) : .merge(zip: code, country: country) current_weather() end |