Class: WeatherFetcher::Provider::OnetPl
- Inherits:
-
HtmlBasedProvider
- Object
- WeatherFetcher::Provider
- HtmlBasedProvider
- WeatherFetcher::Provider::OnetPl
- Defined in:
- lib/weather_fetcher/providers/html_based/onet_pl.rb
Constant Summary
Constants inherited from HtmlBasedProvider
HtmlBasedProvider::TYPE, HtmlBasedProvider::USER_AGENT
Constants inherited from WeatherFetcher::Provider
Instance Attribute Summary
Attributes inherited from WeatherFetcher::Provider
Class Method Summary collapse
Instance Method Summary collapse
-
#_process_body_long_term(body_raw) ⇒ Object
Process response body and rip out weather data, details.
- #process(string) ⇒ Object
Methods inherited from HtmlBasedProvider
#can_fetch?, #fetch_and_process_single, #fetch_url, #fetch_url_old, #url, weather_updated_every
Methods inherited from WeatherFetcher::Provider
#can_fetch?, #fetch, #fetch_and_process_single, #initialize, #provider_name, #provider_params, #short_class_name, short_class_name, #store_city_definition, #store_time_costs, #unix_time_today, #url
Constructor Details
This class inherits a constructor from WeatherFetcher::Provider
Class Method Details
.provider_name ⇒ Object
9 10 11 |
# File 'lib/weather_fetcher/providers/html_based/onet_pl.rb', line 9 def self.provider_name "Onet.pl" end |
Instance Method Details
#_process_body_long_term(body_raw) ⇒ Object
Process response body and rip out weather data, details
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/weather_fetcher/providers/html_based/onet_pl.rb', line 20 def _process_body_long_term(body_raw) data = Array.new b = Nokogiri::HTML(body_raw) weather_days = b.css(".day-longterm") weather_days.each do |weather_day| time_from = Time.parse(weather_day.css("time").attribute("datetime").value.to_s) temp = weather_day.css(".temp").children.first.to_s.to_f desc = weather_day.css(".details").children.collect { |d| d.to_s.gsub(/\n/, "").gsub(/\t/, "") } pressure = desc[3].to_f wind = desc[7].to_f rain = desc[10].gsub(/,/, '.').to_f h = { :time_created => Time.now, :time_from => time_from, :time_to => time_from + 24*3600, :temperature => temp, #:feel_temperature => feel_temp, :pressure => pressure, :wind_kmh => wind, :wind => wind / 3.6, # :snow => nil, #snows[0][0].to_f, :rain => rain, #:cloud_cover => cloud_cover, #:humidity => humidity, :provider => self.class.provider_name } data << h # puts h.inspect end return data end |
#process(string) ⇒ Object
13 14 15 16 17 |
# File 'lib/weather_fetcher/providers/html_based/onet_pl.rb', line 13 def process(string) a = Array.new a += WeatherData.factory(_process_body_long_term(string)) return a end |