Class: Barometer::WeatherService::WeatherBug
- Inherits:
-
Object
- Object
- Barometer::WeatherService::WeatherBug
show all
- Defined in:
- lib/barometer/weather_services/weather_bug.rb,
lib/barometer/weather_services/weather_bug/query.rb,
lib/barometer/weather_services/weather_bug/current_api.rb,
lib/barometer/weather_services/weather_bug/forecast_api.rb,
lib/barometer/weather_services/weather_bug/response/sun.rb,
lib/barometer/weather_services/weather_bug/current_response.rb,
lib/barometer/weather_services/weather_bug/response/station.rb,
lib/barometer/weather_services/weather_bug/forecast_response.rb,
lib/barometer/weather_services/weather_bug/response/location.rb,
lib/barometer/weather_services/weather_bug/response/timezone.rb,
lib/barometer/weather_services/weather_bug/response/time_helper.rb,
lib/barometer/weather_services/weather_bug/response/current_weather.rb,
lib/barometer/weather_services/weather_bug/response/forecasted_weather.rb
Defined Under Namespace
Classes: CurrentApi, CurrentResponse, ForecastApi, ForecastResponse, Query, Response
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(query, config = {}) ⇒ WeatherBug
13
14
15
16
|
# File 'lib/barometer/weather_services/weather_bug.rb', line 13
def initialize(query, config={})
@query = query
@api_code = config[:keys][:code] if config[:keys]
end
|
Class Method Details
.call(query, config = {}) ⇒ Object
9
10
11
|
# File 'lib/barometer/weather_services/weather_bug.rb', line 9
def self.call(query, config={})
WeatherBug.new(query, config).measure!
end
|
Instance Method Details
#measure! ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/barometer/weather_services/weather_bug.rb', line 18
def measure!
validate_key!
current_weather_api = CurrentApi.new(query, api_code)
response = CurrentResponse.new.parse(current_weather_api.get)
forecast_weather_api = ForecastApi.new(current_weather_api.query, api_code)
ForecastResponse.new(response).parse(forecast_weather_api.get)
end
|