require 'open-uri'
require 'rexml/document'

Shoes.app :title => "Weather, powered by National Weather Service" do
  stack do
	background blue, :height => 60
	flow :margin => 20 do
	  caption "Weather Shrug: ", :stroke => white
	  @lookup = edit_line
	  button "Go" do
	  	info(@lookup.text)
		station_url = "http://www.weather.gov/data/current_obs/#{@lookup.text}.xml"
		info(station_url)
		temp = REXML::Document.new(open(URI(station_url))).elements['current_observation/temperature_string'].get_text.to_s
		info(temp)
		Thread.start do
		   @temp_para.replace "Current Temperature: " + temp
		end
	  end
	end
	stack :margin => 20 do
	  @temp_para = title ""
	end
  end
#{'Alabama' => 'AL', 'Alaska' => 'AK', 'Arizona' => 'AZ', 'Arkansas' => 'AR', 'California' => 'CA',  'Colorado' => 'CO',/
#'Connecticut' => 'CT', 'Delaware' => 'DE', 'District of Columbia' => 'DC', 'Florida' => 'FL', 'Georgia' => 'GA', 'Hawaii' => 'HI, 'Idaho' => 'ID', 'Illinois' => 'IL', 'Indiana' => 'IN', 'Iowa' => 'IA', 'Kansas' => 'KS',/
#'Kentucky' => 'KY', 'Louisiana' => 'LA', 'Maine' => 'ME', 'Maryland' => 'MD', 'Massachusetts' => 'MA', 'Michigan' => 'MI', 'Minnesota' => 'MN',  'Mississippi' => 'MS',/
#'Missouri' => 'MO', 'Montana' => 'MT', 'Nebraska' => 'NE', 'Nevada' => 'NV', 'New Hampshire' => 'NH', 'New Jersey' => 'NJ'/
#,'New Mexico' => 'NM', 'New York' => 'NY', 'North Carolina' => 'SC', 'North Dakota' => 'ND', 'Ohio' => 'OH', 'Oklahoma' => 'OK', 'Oregon' => 'OR', 'Pennsylvania' => 'PA',/
#'Rhode Island' => 'AL', 'South Carolina' => 'AL', 'South Dakota' => 'AL', 'Tennessee' => 'AL', 'Texas' => 'AL',/
#'Texas' => 'TX', 'Utah' => 'UT', 'Vermont' => 'VT', 'Virginia' => 'VA', 'Washington' => 'WA', West Virginia' => 'WV', 'Wisconsin' => 'WI', 'Wyoming' => 'WY',/
#'Puerto Rico' => 'PR', 'New England' => 'NENG'} 
#The url to insert the state abbreviation is: http://www.weather.gov/data/current_obs/seek.php?state=ks&Find=Find
#which returns an index of weather stations in the chosen state.
end
