Method: OWMO.weather
- Defined in:
- lib/owmo.rb
.weather(api_key, **kwargs) ⇒ Object
rdoc Yield a weather object for querying weather data
Attributes
-
api_key:- OpenWeatherMap.org API key
Examples
-
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
29 30 31 32 33 34 35 36 37 |
# File 'lib/owmo.rb', line 29 def self.weather(api_key, **kwargs) OWMO::Weather.new(api_key, **kwargs) do |weather| if block_given? yield weather else weather end end end |