Sha256: 8a9da6ebbbacfb78beb9d5d323a99f1181fe807b1f062cd4664d1653451462d3
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
module Vatbook class BookFetcher require 'nokogiri' require 'open-uri' attr_accessor :fir, :atc_bookings, :pilot_bookings, :enroute, :doc def initialize(fir, args = nil) @fir = fir.upcase @enroute = true process_arguments(args) if args.class == Hash @atc_bookings = []; @pilot_bookings = []; @doc = raw_list atcs pilots end def raw_list Nokogiri::XML(open("http://vatbook.euroutepro.com/xml2.php?fir=#{@fir}")) end def fetch {:atc => atc_bookings, :pilots => pilot_bookings} end def atc_bookings @atc_bookings end def pilot_bookings @pilot_bookings end def atcs_count @doc.css("atcs booking").count end def pilots_count @doc.css("pilots booking").count end private def atcs @doc.css("atcs booking").each do |booking| @atc_bookings << Booking.new(booking, role = "atc", @fir) end end def pilots @doc.css("pilots booking").each do |booking| if @enroute == false bk = Booking.new(booking, role = "pilot", @fir) if bk.enroute == false @pilot_bookings << bk end else @pilot_bookings << Booking.new(booking, role = "pilot", @fir) end end end def process_arguments(args) args[:enroute] == false ? @enroute = false : @enroute = true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vatbook-0.2.1 | lib/vatbook/book_fetcher.rb |
vatbook-0.2.0 | lib/vatbook/book_fetcher.rb |