Class: Vatbook::BookFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/vatbook/book_fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fir, args = nil) ⇒ BookFetcher

Returns a new instance of BookFetcher.



9
10
11
12
13
14
15
16
17
# File 'lib/vatbook/book_fetcher.rb', line 9

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

Instance Attribute Details

#atc_bookingsObject

Returns the value of attribute atc_bookings.



7
8
9
# File 'lib/vatbook/book_fetcher.rb', line 7

def atc_bookings
  @atc_bookings
end

#docObject

Returns the value of attribute doc.



7
8
9
# File 'lib/vatbook/book_fetcher.rb', line 7

def doc
  @doc
end

#enrouteObject

Returns the value of attribute enroute.



7
8
9
# File 'lib/vatbook/book_fetcher.rb', line 7

def enroute
  @enroute
end

#firObject

Returns the value of attribute fir.



7
8
9
# File 'lib/vatbook/book_fetcher.rb', line 7

def fir
  @fir
end

#pilot_bookingsObject

Returns the value of attribute pilot_bookings.



7
8
9
# File 'lib/vatbook/book_fetcher.rb', line 7

def pilot_bookings
  @pilot_bookings
end

Instance Method Details

#atcs_countObject



35
36
37
# File 'lib/vatbook/book_fetcher.rb', line 35

def atcs_count
  @doc.css("atcs booking").count
end

#fetchObject



23
24
25
# File 'lib/vatbook/book_fetcher.rb', line 23

def fetch
   {:atc => atc_bookings, :pilots => pilot_bookings}
end

#pilots_countObject



39
40
41
# File 'lib/vatbook/book_fetcher.rb', line 39

def pilots_count
  @doc.css("pilots booking").count
end

#raw_listObject



19
20
21
# File 'lib/vatbook/book_fetcher.rb', line 19

def raw_list
  Nokogiri::XML(open("http://vatbook.euroutepro.com/xml2.php?fir=#{@fir}"))
end