Last active
          October 5, 2015 09:07 
        
      - 
      
 - 
        
Save ksaynice/446f5bc1b74c77555dc7 to your computer and use it in GitHub Desktop.  
    Weather via ruby
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env ruby -wKU | |
| # | |
| require 'rexml/document' | |
| xml = `curl -s "http://www.google.com/ig/api?weather=94030"` | |
| doc = REXML::Document.new(xml) | |
| condition = doc.root.elements["weather/current_conditions/condition"].attributes['data'] | |
| wind_condition = doc.root.elements["weather/current_conditions/wind_condition"].attributes['data'] | |
| wind_condition = wind_condition.match(/\d+/).to_s | |
| temp_f = doc.root.elements["weather/current_conditions/temp_f"].attributes['data'] | |
| forcast = doc.root.elements["weather/forecast_conditions/high"].attributes['data'] | |
| s = "It's #{condition}, #{temp_f} degrees, wind at #{wind_condition} mph, with a high of #{forcast}." | |
| puts s | |
| `say "#{s}"` | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment