Class: ATCTools::Aircraft
- Inherits:
-
Object
- Object
- ATCTools::Aircraft
- Defined in:
- lib/atc-tools/aircraft.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Aircraft code.
-
#equipment ⇒ Object
readonly
Aircraft equipment code.
-
#info ⇒ Object
Full aircraft info string.
-
#model ⇒ Object
readonly
Aircraft model number.
-
#raw ⇒ Object
readonly
Raw data used to initialize the object, typically from the VRC client.
Instance Method Summary collapse
-
#initialize(aircraft_code = nil, **kvargs) ⇒ Aircraft
constructor
Params: :info, :model, :code, :equipment – See instance variables for descriptions.
-
#to_s ⇒ Object
Returns @raw.
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
#code ⇒ Object (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 |
#equipment ⇒ Object (readonly)
Aircraft equipment code.
14 15 16 |
# File 'lib/atc-tools/aircraft.rb', line 14 def equipment @equipment end |
#info ⇒ Object
Full aircraft info string.
7 8 9 |
# File 'lib/atc-tools/aircraft.rb', line 7 def info @info end |
#model ⇒ Object (readonly)
Aircraft model number.
12 13 14 |
# File 'lib/atc-tools/aircraft.rb', line 12 def model @model end |
#raw ⇒ Object (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_s ⇒ Object
Returns @raw.
31 32 33 |
# File 'lib/atc-tools/aircraft.rb', line 31 def to_s @raw end |