class NoaaWeatherClient::Services::ForecastByDay

Attributes

options[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 9
def initialize(options = {})
  @options = options
end

Public Instance Methods

fetch(lat, lon, options = {}) click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 13
def fetch(lat, lon, options = {})
  fopts = build_formated_options options.merge({ latitude: lat.to_s, longitude: lon.to_s })
  soap_service.object_from_response(:ndf_dgen_by_day, fopts, response_class: response_class)
end

Private Instance Methods

build_formated_options(options) click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 30
def build_formated_options(options)
  opts = options.dup
  {
    latitude: opts.delete(:latitude),
    longitude: opts.delete(:longitude),
    startDate: opts.delete(:start_date) { Date.today.to_s },
    numDays: opts.delete(:days) { 7 },
    unit: unit!(opts),
    format: opts.delete(:format) { '24 hourly' }
  }.merge!(opts)
end
response_class() click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 26
def response_class
  options.fetch(:response_class, Responses::Forecast)
end
soap_service() click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 22
def soap_service
  options.fetch(:soap_service, self)
end
unit!(options) click to toggle source
# File lib/noaa_weather_client/services/forecast_by_day.rb, line 42
def unit!(options)
  u = options.delete(:unit) { :standard }
  if u == :standard
    'e'
  elsif u == :metric
    'm'
  end
end