Method: NacoInterface#cycles

Defined in:
lib/nacofetch/naco_interface.rb

#cyclesObject



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