Class: Barometer::Noaa

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/noaa.rb,
lib/barometer/noaa/version.rb,
lib/barometer/noaa/current_api.rb,
lib/barometer/noaa/forecast_api.rb,
lib/barometer/noaa/current_query.rb,
lib/barometer/noaa/forecast_query.rb,
lib/barometer/noaa/current_response.rb,
lib/barometer/noaa/forecast_response.rb,
lib/barometer/noaa/response/location.rb,
lib/barometer/noaa/response/timezone.rb,
lib/barometer/noaa/response/current_station.rb,
lib/barometer/noaa/response/current_weather.rb,
lib/barometer/noaa/response/current_location.rb,
lib/barometer/noaa/response/forecasted_weather.rb

Defined Under Namespace

Classes: CurrentApi, CurrentQuery, CurrentResponse, ForecastApi, ForecastQuery, ForecastResponse, Response

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Noaa

Returns a new instance of Noaa.



14
15
16
# File 'lib/barometer/noaa.rb', line 14

def initialize(query)
  @query = query
end

Class Method Details

.call(query, config = {}) ⇒ Object



10
11
12
# File 'lib/barometer/noaa.rb', line 10

def self.call(query, config={})
  Noaa.new(query).measure!
end

Instance Method Details

#measure!Object



18
19
20
21
22
23
24
25
# File 'lib/barometer/noaa.rb', line 18

def measure!
  forecast_weather_api = ForecastApi.new(query)
  response = ForecastResponse.new.parse(forecast_weather_api.get)
  forecast_weather_api.query.add_conversion(:coordinates, response.location.coordinates)

  current_weather_api = CurrentApi.new(forecast_weather_api.query)
  CurrentResponse.new(response).parse(current_weather_api.get)
end