Class: ATCTools::Aircraft

Inherits:
Object
  • Object
show all
Defined in:
lib/atc-tools/aircraft.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aircraft_code = nil, **kvargs) ⇒ Aircraft

Params:

:info, :model, :code, :equipment
-- See instance variables for descriptions.


19
20
21
22
23
24
25
26
27
28
# File 'lib/atc-tools/aircraft.rb', line 19

def initialize(aircraft_code = nil, **kvargs)
  @raw       = aircraft_code || kvargs.fetch(:code, '')
  @info      = kvargs.fetch :info, ''
  @model     = kvargs.fetch :model, ''
  
  params     = @raw.scan(%r{(?:([a-zA-Z]+)/)?(\w+)(?:/([a-zA-Z]+))?}).flatten
  
  @code      = kvargs.fetch(:code, nil) || params[1] || ''
  @equipment = kvargs.fetch(:equipment, nil) || params[2] || ''
end

Instance Attribute Details

#codeObject (readonly)

Aircraft code. The identifier that would be displayed on the radar scope (B732 = Boeing 737-200).



10
11
12
# File 'lib/atc-tools/aircraft.rb', line 10

def code
  @code
end

#equipmentObject (readonly)

Aircraft equipment code.



14
15
16
# File 'lib/atc-tools/aircraft.rb', line 14

def equipment
  @equipment
end

#infoObject

Full aircraft info string.



7
8
9
# File 'lib/atc-tools/aircraft.rb', line 7

def info
  @info
end

#modelObject (readonly)

Aircraft model number.



12
13
14
# File 'lib/atc-tools/aircraft.rb', line 12

def model
  @model
end

#rawObject (readonly)

Raw data used to initialize the object, typically from the VRC client.



5
6
7
# File 'lib/atc-tools/aircraft.rb', line 5

def raw
  @raw
end

Instance Method Details

#to_sObject

Returns @raw.



31
32
33
# File 'lib/atc-tools/aircraft.rb', line 31

def to_s
  @raw
end