Ruby API to the Vatbook service for reading and parsing Vatsim pilot and ATC bookings. Booking query requests are made by FIR and individual bookings are returned as objects, exposing a rich set of attributes. Supports excluding enroute pilot bookings. Supports pulling pilot and atc bookings separately or as a combined hash.
Ruby 1.9.3 or higher | Supports Ruby 2.0!
Add this line to your application's Gemfile:
gem 'vatbook'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vatbook
This gem provides one public method: vatbook
, which can be applied to
any string (or variable containing a string) representing a full or partial FIR
ICAO code.
For example if you want to retrieve all active stations (ATC positions and pilots) for Bosnia-Herzegovina FIR (ICAO: LQSB), then you can use:
# Attaching the method directly to a string:
"LQSB".vatbook
# Attaching the method to a variable containing a string:
fir = "LQSB"
fir.vatbook
The vatbook
method returns a hash of 2 elements: 1) the matching atc
bookings, 2) all matching pilots bookings. Each of those is an array, cosnsisting of
station objects. Each of these objects includes a number of attributes:
fir.vatbook # => {:atc => [a1, a2, a3 ...], :pilots => [p1, p2, p3, p4 ...]}
fir.vatbook[:atc] #=> [a1, a2, a3 ...]
fir.vatbook[:pilots] #=> [p1, p2, p3 ...]
fir.vatbook[:atc].first #=> a1
fir.vatbook[:pilots].first #=> p1
a1.callsign #=> "LQSA_APP"
a1.name #=> "Svilen Vassilev"
a1.cid #=> "1175035"
a1.start #=> "2012-10-08 08:00:00"
a1.end #=> "2012-10-08 10:00:00"
...
p1.callsign #=> "ACH217S"
p1.name #=> "Dragomir Andonovic"
p1.cid #=> "931960"
p1.dep #=> "LQSA"
p1.arr #=> "LDSP"
p1.route #=> "VRANA L5 KENEM"
p1.aircraft #=> "AT72"
...
Here's a complete list of the station object attributes that can be accessed:
cid
(VATSIM ID)callsign
name
role
(atc or pilot)fir
(the FIR ICAO used in the request)start
(planned start time)end
(planned end time)
dep
(planned departure airport)arr
(planned destination airport)route
(planned route)aircraft
(planned aircraft type)enroute
(boolean, whether or not the flight is enroute for the FIR)
The vatbook
method can be customized by passing in a hash-style collection
of arguments. The currently supported arguments and their defaults are:
:enroute => true # Possible values: true, false. Default: true
The :enroute => false
option can be used to exclude all booked flights that
are enroute for the selected FIR, i.e. don't originate or end on one of the FIR's
airports. Example:
# Lets exclude all enroute pilot bookings for LQSB FIR and only display bookings
# that are outbound/inbound one of Bosnia-Herzegovina airports:
"LQSB".vatbook(:enroute => false) #=> [pilot1, pilot2, pilot3...]
- Ruby 2.0 support
- dependencies update
- classes refactored
- Initial release
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Make sure all tests pass
- Create new Pull Request
Copyright © 2013 Svilen Vassilev
If you find my work useful or time-saving, you can endorse it or buy me a cup of coffee:
Released under the MIT LICENSE