Module: WeatherJudge

Extended by:
Configuration
Defined in:
lib/weather_judge/weather_data.rb,
lib/weather_judge.rb,
lib/weather_judge/version.rb,
lib/weather_judge/configuration.rb

Overview

Calculates score for 4 different weather aspects: sky cover, chance of rain, wind, and temperature

Defined Under Namespace

Modules: Configuration Classes: WeatherData

Constant Summary collapse

VERSION =
"0.1.2"

Instance Attribute Summary

Attributes included from Configuration

#forecast_io_api_key, #ideal_temp_range, #max_cloud_cover, #max_percent_rain, #max_wind_speed, #temp_range_delta

Class Method Summary collapse

Methods included from Configuration

configure

Class Method Details

.run(latitude, longitude) ⇒ Object

Retrieves WeatherData object for today’s forecast given latitude and longitude.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/weather_judge.rb', line 12

def run(latitude, longitude)
  validate_coordinates(latitude, longitude)

  ForecastIO.api_key = WeatherJudge.forecast_io_api_key
  forecast = ForecastIO.forecast(latitude, longitude, params: { exclude: 'hourly,minutely,alerts,flags'})

  if forecast.nil?
    raise StandardError.new("Unable to obtain forecast! Check your network connectivity and API key")
  end

  @forecast_today = forecast.daily.data.first

  WeatherData.new(@forecast_today)
end