Class: Apis::Weather

Inherits:
Object
  • Object
show all
Defined in:
lib/apis/endpoints/weather.rb

Overview

Class to fetch weather

Instance Method Summary collapse

Instance Method Details

#forecasts(stations, lang = 'is') ⇒ Faraday::Response

Get weather forecast for Iceland.

Parameters:

  • stations (Array)

    list of stations (required)

  • lang (String) (defaults to: 'is')

    result language (optional)

Returns:

  • (Faraday::Response)

    Api result.



11
12
13
14
# File 'lib/apis/endpoints/weather.rb', line 11

def forecasts(stations, lang = 'is')
  Apis.client.get("/weather/forecasts/#{lang}" \
    "/?stations=#{stations.join(',')}")
end

#observations(stations, lang = 'is', time = '1h', anytime = '0') ⇒ Faraday::Response

Get weather observations for Iceland.

or 3h for mixed data (optional)

Parameters:

  • stations (Array)

    list of stations (required)

  • lang (String) (defaults to: 'is')

    result language (optional)

  • time (String) (defaults to: '1h')

    1h for automatic stations

  • anytime (String) (defaults to: '0')

    (optional)

Returns:

  • (Faraday::Response)

    Api result.



24
25
26
27
# File 'lib/apis/endpoints/weather.rb', line 24

def observations(stations, lang = 'is', time = '1h', anytime = '0')
  Apis.client.get("/weather/forecasts/#{lang}" \
    "/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}")
end

#texts(types) ⇒ Faraday::Response

Get weather information texts for Iceland.

Parameters:

  • types (Array)

    list of types (required)

Returns:

  • (Faraday::Response)

    Api result.



33
34
35
# File 'lib/apis/endpoints/weather.rb', line 33

def texts(types)
  Apis.client.get("/weather/texts?types=#{types.join(',')}")
end