class Helpers

Public Instance Methods

cords_to_url(url, coords, api_key, units, lang) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 32
def cords_to_url(url, coords, api_key, units, lang)
  "#{url}lat=#{coords[1]}&lon=#{coords[0]}&appid=#{api_key}&lang=#{lang}&units=#{units}"
end
find_to_url(url, coords, count, api_key, units, lang) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 40
def find_to_url(url, coords, count, api_key, units, lang)
  "#{url}lat=#{coords[1]}&lon=#{coords[0]}&appid=#{api_key}&cnt=#{count}&lang=#{lang}&units=#{units}"
end
id_to_url(url, name, api_key, units, lang) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 28
def id_to_url(url, name, api_key, units, lang)
  "#{url}id=#{name}&appid=#{api_key}&lang=#{lang}&units=#{units}"
end
name_to_url(url, name, api_key, units, lang) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 24
def name_to_url(url, name, api_key, units, lang)
  "#{url}q=#{name}&appid=#{api_key}&lang=#{lang}&units=#{units}"
end
swtich_url(method) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 13
def swtich_url(method)
  case method
  when 'current_wether'
    'https://api.openweathermap.org/data/2.5/weather?'
  when 'hourly'
    'pro.openweathermap.org/data/2.5/forecast/hourly?'
  when 'find'
    'api.openweathermap.org/data/2.5/find?'
  end
end
to_json(data) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 5
def to_json(data)
  unless data
    tmp = {}
    return JSON.parse(tmp)
  end
  JSON.parse data
end
zipcode_to_url(url, zip, country, api_key, units, lang) click to toggle source
# File lib/open_weather/helpers/helpers.rb, line 36
def zipcode_to_url(url, zip, country, api_key, units, lang)
  "#{url}zip=#{zip},#{country}&appid=#{api_key}&lang=#{lang}&units=#{units}"
end