Class: Weatheruby

Inherits:
Object
  • Object
show all
Includes:
Weather::Actions, Weather::Planner
Defined in:
lib/weatheruby.rb

Defined Under Namespace

Classes: WeatherError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Weather::Planner

#chance_of_cloudy, #chance_of_fog, #chance_of_freezing, #chance_of_groundsnow, #chance_of_hail, #chance_of_heat, #chance_of_high_wind, #chance_of_humid, #chance_of_not_freezing, #chance_of_partlycloudy, #chance_of_precipitation, #chance_of_rain, #chance_of_snow, #chance_of_sultry, #chance_of_sunny, #chance_of_thunderstorms, #chance_of_tornado, #chance_of_warmth, #get_dewpoints, #get_precipitation, #get_temperatures

Methods included from Weather::Actions

#alerts, #complex_forecast, #complex_forecast_10day, #conditions, #hurricane_data, #moon_phase, #record_high, #record_low, #simple_forecast, #simple_forecast_10day, #sun_info

Constructor Details

#initialize(api_key, language = 'EN', use_pws = true, use_bestfct = true) ⇒ Weatheruby

Creates a new instance of Weatheruby.

Parameters:

  • api_key (String)

    Your personal API key obtained on sign up for Weather Underground.

  • language (String) (defaults to: 'EN')

    The language code you would like to use.

  • use_pws (Boolean) (defaults to: true)

    Whether to use the Personal Weather Station feature.

  • use_bestfct (Boolean) (defaults to: true)

    Whether to use BestForecast.



33
34
35
36
37
38
39
40
# File 'lib/weatheruby.rb', line 33

def initialize(api_key, language = 'EN', use_pws = true, use_bestfct = true)
  @api_key = api_key
  @language_key = language.upcase
  @use_pws = use_pws ? 1 : 0
  @use_bestfct = use_bestfct ? 1 : 0

  @client = HTTPClient.new
end

Instance Attribute Details

#language_keyObject

Returns the value of attribute language_key.



26
27
28
# File 'lib/weatheruby.rb', line 26

def language_key
  @language_key
end