class MeteoPl::Utility::MobileMeteoGraph
Constants
- FORM_URL
Attributes
graph_page[R]
initial_request_uri[R]
initial_response[R]
Public Instance Methods
uri()
click to toggle source
# File lib/meteo_pl/utility/graph.rb, line 20 def uri @uri ||= begin prepare_initial_request_uri fetch_initial_data return unless initial_response && initial_response.code == '302' fetch_graph_page fetch_graph_uri end end
Private Instance Methods
fetch_graph_page()
click to toggle source
# File lib/meteo_pl/utility/graph.rb, line 52 def fetch_graph_page @graph_page = net_fetcher.fetch(URI(initial_response['location']), &:body) end
fetch_graph_uri()
click to toggle source
# File lib/meteo_pl/utility/graph.rb, line 57 def fetch_graph_uri URI(graph_page.match(/http.+mgram_pict\.php([^"]+)/)[0]) end
fetch_initial_data()
click to toggle source
# File lib/meteo_pl/utility/graph.rb, line 46 def fetch_initial_data net_fetcher.fetch(initial_request_uri) do |response| @initial_response = response end end
prepare_initial_request_uri()
click to toggle source
# File lib/meteo_pl/utility/graph.rb, line 34 def prepare_initial_request_uri @initial_request_uri = begin uri = URI(FORM_URL) uri.query = URI.encode_www_form( miastoPL: location, typePL: :city, prognozaPL: period ) uri end end