Sha256: 6e857d468d989f89d57d5de8ccdc95bc6f76883f8bbb539e92126ef01e98facb
Contents?: true
Size: 787 Bytes
Versions: 3
Compression:
Stored size: 787 Bytes
Contents
require 'net/http' # All ugly providers who parse even uglier html code and rip off data module WeatherFetcher class HtmlBasedProvider < Provider TYPE = :html_based # Get processed weather for one definition def fetch_and_process_single(p) return nil unless can_fetch?(p) body = fetch_url(url(p)) processed = process(body) return processed end # Download url def fetch_url(url) return Net::HTTP.get(URI.parse(url)) end # Url for current provider def url(p) provider_params(p)[:url] end def can_fetch?(p) begin url(p).nil? == false rescue false end end # How often weather is updated def self.weather_updated_every 4*HOUR end end end
Version data entries
3 entries across 3 versions & 1 rubygems