Class: Barometer::Noaa::ForecastQuery

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/barometer/noaa/forecast_query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ ForecastQuery

Returns a new instance of ForecastQuery.



12
13
14
15
# File 'lib/barometer/noaa/forecast_query.rb', line 12

def initialize(query)
  super
  @converted_query = convert_query
end

Instance Attribute Details

#converted_queryObject (readonly)

Returns the value of attribute converted_query.



6
7
8
# File 'lib/barometer/noaa/forecast_query.rb', line 6

def converted_query
  @converted_query
end

Class Method Details

.accepted_formatsObject



8
9
10
# File 'lib/barometer/noaa/forecast_query.rb', line 8

def self.accepted_formats
  [:zipcode, :coordinates]
end

Instance Method Details

#to_paramObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/barometer/noaa/forecast_query.rb', line 17

def to_param
  case converted_query.format.to_sym
  when :short_zipcode
    {zipCodeList: converted_query.q}
  when :zipcode
    {zipCodeList: converted_query.q}
  when :coordinates
    {lat: converted_query.q.split(',')[0], lon: converted_query.q.split(',')[1]}
  else
    {}
  end
end