Class: NacoInterface
- Inherits:
-
Object
- Object
- NacoInterface
- Defined in:
- lib/nacofetch/naco_interface.rb
Instance Method Summary collapse
- #current_cycle ⇒ Object
- #cycles ⇒ Object
- #fetch_plates_for_airport(metafile_url, ident) ⇒ Object
- #fetch_plates_for_state(metafile_url, statecode) ⇒ Object
- #fetch_plates_for_volume(metafile_url, volumecode) ⇒ Object
-
#initialize ⇒ NacoInterface
constructor
A new instance of NacoInterface.
- #metafile_for_cycle(cycle) ⇒ Object
- #pending_cycle ⇒ Object
Constructor Details
#initialize ⇒ NacoInterface
Returns a new instance of NacoInterface.
12 13 14 |
# File 'lib/nacofetch/naco_interface.rb', line 12 def initialize @base_url = "http://aeronav.faa.gov" end |
Instance Method Details
#current_cycle ⇒ Object
38 39 40 |
# File 'lib/nacofetch/naco_interface.rb', line 38 def current_cycle self.cycles.select { |cycle| cycle.status == "CURRENT" }.first end |
#cycles ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nacofetch/naco_interface.rb', line 16 def cycles unless @cycles_var url = "/index.asp?xml=aeronav/applications/d_tpp" doc = Nokogiri::HTML(open(@base_url + url)) @cycles_var = [] tables = doc.xpath('//table[@title="Digital Terminal Procedures Publication"]') tables.xpath('//td[@headers="header1"]').each do |cycle| url = cycle.xpath('./a/@href').to_s() @cycles_var << Cycle.new( url.sub(/digital_tpp/, "digital_tpp_search"), # todo: there's gotta be a less hacky way to do this' /ver=(\d+)/.match(url)[1], string_to_time(/eff=(\d+-\d+-\d+)/.match(url)[1], '%m-%d-%Y'), string_to_time(/end=(\d+-\d+-\d+)/.match(url)[1], '%m-%d-%Y') ) end end @cycles_var end |
#fetch_plates_for_airport(metafile_url, ident) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/nacofetch/naco_interface.rb', line 51 def fetch_plates_for_airport(, ident) xpath = "/digital_tpp/state_code/city_name/airport_name[@icao_ident = '#{ident}' or @apt_ident = '#{ident}']" #xpath = "/digital_tpp/state_code[@ID = 'GA']" fetch_plates_for_xpath(, xpath) end |
#fetch_plates_for_state(metafile_url, statecode) ⇒ Object
58 59 60 61 62 |
# File 'lib/nacofetch/naco_interface.rb', line 58 def fetch_plates_for_state(, statecode) xpath = "/digital_tpp/state_code[@ID = '#{statecode}']" fetch_plates_for_xpath(, xpath) end |
#fetch_plates_for_volume(metafile_url, volumecode) ⇒ Object
64 65 66 67 68 |
# File 'lib/nacofetch/naco_interface.rb', line 64 def fetch_plates_for_volume(, volumecode) xpath = "/digital_tpp/state_code[city_name/@volume = '#{volumecode}']" fetch_plates_for_xpath(, xpath) end |
#metafile_for_cycle(cycle) ⇒ Object
46 47 48 49 |
# File 'lib/nacofetch/naco_interface.rb', line 46 def (cycle) (cycle) unless File.exists?((cycle)) (cycle) end |
#pending_cycle ⇒ Object
42 43 44 |
# File 'lib/nacofetch/naco_interface.rb', line 42 def pending_cycle self.cycles.select { |cycle| cycle.status == "PENDING" }.first end |