Created
March 30, 2011 01:58
-
-
Save yock/893727 to your computer and use it in GitHub Desktop.
This file contains 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
require 'net/ftp' | |
require 'time' | |
metar_uri = 'tgftp.nws.noaa.gov' | |
metar_base = '/data/observations/metar/stations/' | |
metar_station = ARGV[0] | |
metar_file = metar_station + '.TXT' | |
metar_data = Array.new | |
Net::FTP.open metar_uri do |conn| | |
conn.login | |
conn.chdir metar_base | |
conn.gettextfile metar_file do |line| | |
line.split(" ").each do |token| | |
metar_data.push token | |
end | |
end | |
end | |
str_datetime = metar_data[0] + " " + metar_data[1] + " UTC" | |
metar_datetime = Time.parse str_datetime | |
puts metar_datetime.localtime | |
puts metar_data.to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment