Skip to content

Instantly share code, notes, and snippets.

@yock
Created March 30, 2011 01:58
Show Gist options
  • Save yock/893727 to your computer and use it in GitHub Desktop.
Save yock/893727 to your computer and use it in GitHub Desktop.
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