module Accuweather
Constants
- VERSION
Public Class Methods
city_search(name:)
click to toggle source
# File lib/accuweather.rb, line 19 def self.city_search(name:) @cache ||= Accuweather::Location::Cache.new cache_result = @cache.cities(name: name) return cache_result unless cache_result == [] response = Net::HTTP.get('samsungmobile.accu-weather.com', "/widget/samsungmobile/city-find.asp?returnGeoPosition=1&location=#{name}") Accuweather::Location::Parser.new(response).cities rescue StandardError => e raise Accuweather::Error.new("#{e.class}: #{e.message}") end
get_conditions(location_id:, metric: false)
click to toggle source
# File lib/accuweather.rb, line 32 def self.get_conditions(location_id:, metric: false) metric_value = metric ? '1' : '0' response = Net::HTTP.get('samsungmobile.accu-weather.com', "/widget/samsungmobile/weather-data.asp?metric=#{metric_value}&location=#{location_id}") Accuweather::Conditions::Parser.new(response) rescue StandardError => e raise Accuweather::Error.new("#{e.class}: #{e.message}") end