Class: OpenMeteo::Forecast
- Inherits:
-
Object
- Object
- OpenMeteo::Forecast
- Defined in:
- lib/open_meteo/forecast.rb,
lib/open_meteo/forecast/variables.rb
Overview
Perform a forecast request to the OpenMeteo API.
Defined Under Namespace
Classes: ForecastModelNotImplemented, Variables, WrongLocationType
Constant Summary collapse
- AVAILABLE_FORECAST_MODELS =
{ general: { # See https://open-meteo.com/en/docs endpoint: :forecast, }, dwd_icon: { # See https://open-meteo.com/en/docs/dwd-api endpoint: :forecast_dwd_icon, }, }.freeze
Instance Method Summary collapse
- #get(location:, variables:, model: :general) ⇒ Object
-
#initialize(config: OpenMeteo::Client::Config.new, client: OpenMeteo::Client.new(config:), response_wrapper: OpenMeteo::ResponseWrapper.new(config:)) ⇒ Forecast
constructor
A new instance of Forecast.
Constructor Details
#initialize(config: OpenMeteo::Client::Config.new, client: OpenMeteo::Client.new(config:), response_wrapper: OpenMeteo::ResponseWrapper.new(config:)) ⇒ Forecast
15 16 17 18 19 20 21 22 |
# File 'lib/open_meteo/forecast.rb', line 15 def initialize( config: OpenMeteo::Client::Config.new, client: OpenMeteo::Client.new(config:), response_wrapper: OpenMeteo::ResponseWrapper.new(config:) ) @client = client @response_wrapper = response_wrapper end |
Instance Method Details
#get(location:, variables:, model: :general) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/open_meteo/forecast.rb', line 24 def get(location:, variables:, model: :general) ensure_valid_location(location) model_definition = get_model_definition(model) variables_object = OpenMeteo::Forecast::Variables.new(**variables) get_forecast(model_definition[:endpoint], location, variables_object) end |