class Barometer::WeatherBug::Query

Attributes

converted_query[R]

Public Class Methods

accepted_formats() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 8
def self.accepted_formats
  [:coordinates]
end
new(query) click to toggle source
Calls superclass method
# File lib/barometer/weather_bug/query.rb, line 12
def initialize(query)
  super
  @converted_query = convert_query
end

Public Instance Methods

to_param() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 17
def to_param
  {
    locationtype: location_type,
    units: units,
    verbose: 'true'
  }.merge(format_query)
end

Private Instance Methods

convert_query() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 27
def convert_query
  convert!(*self.class.accepted_formats)
end
format_query() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 39
def format_query
  if converted_query.geo
    { location: "#{converted_query.geo.latitude},#{converted_query.geo.longitude}" }
  else
    { location: converted_query.to_s }
  end
end
location_type() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 31
def location_type
  'latitudelongitude'
end
units() click to toggle source
# File lib/barometer/weather_bug/query.rb, line 35
def units
  converted_query.metric? ? 'metric' : 'english'
end