class Barometer::Yahoo::Query

Attributes

converted_query[R]

Public Class Methods

accepted_formats() click to toggle source
# File lib/barometer/yahoo/query.rb, line 8
def self.accepted_formats
  [:zipcode, :weather_id, :woe_id]
end
new(query) click to toggle source
Calls superclass method
# File lib/barometer/yahoo/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/yahoo/query.rb, line 17
def to_param
  {u: unit_type}.merge(format_query)
end

Private Instance Methods

convert_query() click to toggle source
# File lib/barometer/yahoo/query.rb, line 23
def convert_query
  convert!(*self.class.accepted_formats)
end
format_query() click to toggle source
# File lib/barometer/yahoo/query.rb, line 27
def format_query
  if converted_query.format == :woe_id
    { w: converted_query.q }
  else
    { p: converted_query.q }
  end
end
unit_type() click to toggle source
# File lib/barometer/yahoo/query.rb, line 35
def unit_type
  converted_query.metric? ? 'c' : 'f'
end