lib/owmo.rb in owmo-1.2.0 vs lib/owmo.rb in owmo-2.0.0
- old
+ new
@@ -1,6 +1,5 @@
-require "owmo/api"
require "owmo/version"
require "owmo/weather"
=begin rdoc
@@ -16,22 +15,28 @@
=begin rdoc
Yield a weather object for querying weather data
==== Attributes
* +api_key:+ - {OpenWeatherMap.org API key}[http://openweathermap.org/appid]
==== Examples
- api_key = "<My API Key>"
- OWMO::weather api_key do |weather|
- puts weather.get :current, city_name: "London,uk"
+* Single request:
+ api_key = ''
+ OWMO::weather(api_key).get :current, city_name: "London,UK"
+* Muliple requests:
+ api_key = ''
+ OWMO::weather(api_key) do |weather|
+ puts weather.get :current, city_name: "London,UK"
+ puts weather.get :forecast5, city_name: "London,UK"
+ puts weather.get :forecast16, city_name: "London,UK"
end
=end
public
def self.weather(api_key, **params)
- weather = Weather.new(api_key, params)
+ Weather.new(api_key, params) do |weather|
+ if block_given?
+ yield weather
+ else
+ return weather
+ end
+ end
+ end
- if block_given?
- yield weather
- else
- return weather
- end # if
- end # weather
-
-end # OWMO
+end