Class: Meteorology::Providers::Yr

Inherits:
Object
  • Object
show all
Defined in:
lib/meteorology/providers/yr.rb

Defined Under Namespace

Classes: XmlParser

Constant Summary collapse

URL =
"http://api.yr.no/weatherapi/locationforecast/1.6/?lat=%s;lon=%s"

Instance Method Summary collapse

Instance Method Details

#load(lat, lng) ⇒ Object



7
8
9
10
11
12
# File 'lib/meteorology/providers/yr.rb', line 7

def load(lat, lng)
  parser = LibXML::XML::SaxParser.string(Net::HTTP.get(URI.parse(URL % [lat, lng])))
  parser.callbacks = XmlParser.new
  parser.parse
  return parser.callbacks.forecasts
end