Class: Thundersnow
- Inherits:
-
Object
- Object
- Thundersnow
- Defined in:
- lib/thundersnow.rb
Class Method Summary collapse
Class Method Details
.run(args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/thundersnow.rb', line 7 def run(args) @args = args location = args.reject {|a| a =~ /^--/ }[0] uri = URI.encode "http://www.google.com/ig/api?weather=#{location}" @xml = Nokogiri::XML(open(uri)) # Invalid locations contain problem_cause xml tag if @xml.xpath('//weather/problem_cause').size > 0 return puts "Could not locate weather for #{location}" end if show_forecast? show :forecast else show :current end end |