Class: AIXM::Z
Overview
Height, elevation or altitude
Shortcuts:
-
AIXM::GROUND
- surface expressed as “0 ft QFE” -
AIXM::UNLIMITED
- no upper limit expressed as “FL 999”
Constant Summary collapse
- CODES =
%i(qfe qnh qne).freeze
Instance Attribute Summary collapse
-
#alt ⇒ Integer
Altitude or elevation value.
-
#code ⇒ Symbol
Q code - either
:qfe
(height in feet),:qnh
(altitude in feet or:qne
(altitude as flight level).
Instance Method Summary collapse
- #==(other) ⇒ Boolean (also: #eql?)
-
#ground? ⇒ Boolean
Whether ground level or not.
- #hash ⇒ Integer
-
#initialize(alt, code) ⇒ Z
constructor
A new instance of Z.
- #inspect ⇒ String
- #qfe? ⇒ Boolean
- #qne? ⇒ Boolean
- #qnh? ⇒ Boolean
-
#to_s ⇒ String
Human readable representation (e.g. “FL045” or “1350 ft QNH”).
-
#unit ⇒ Symbol
Unit - either
:fl
(flight level) or:ft
(feet). -
#zero? ⇒ Boolean
Whether height, elevation or altitude is zero.
Constructor Details
#initialize(alt, code) ⇒ Z
Returns a new instance of Z.
30 31 32 |
# File 'lib/aixm/z.rb', line 30 def initialize(alt, code) self.alt, self.code = alt, code end |
Instance Attribute Details
#alt ⇒ Integer
Returns altitude or elevation value.
25 26 27 |
# File 'lib/aixm/z.rb', line 25 def alt @alt end |
#code ⇒ Symbol
Returns Q code - either :qfe
(height in feet), :qnh
(altitude in feet or :qne
(altitude as flight level).
28 29 30 |
# File 'lib/aixm/z.rb', line 28 def code @code end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
80 81 82 |
# File 'lib/aixm/z.rb', line 80 def ==(other) self.class === other && alt == other.alt && code == other.code end |
#ground? ⇒ Boolean
Returns whether ground level or not.
69 70 71 |
# File 'lib/aixm/z.rb', line 69 def ground? qfe? && @alt == 0 end |
#hash ⇒ Integer
87 88 89 |
# File 'lib/aixm/z.rb', line 87 def hash to_s.hash end |
#inspect ⇒ String
35 36 37 |
# File 'lib/aixm/z.rb', line 35 def inspect %Q(#<#{self.class} #{to_s}>) end |
#qfe? ⇒ Boolean
64 65 66 |
# File 'lib/aixm/z.rb', line 64 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#qne? ⇒ Boolean
64 65 66 |
# File 'lib/aixm/z.rb', line 64 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#qnh? ⇒ Boolean
64 65 66 |
# File 'lib/aixm/z.rb', line 64 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#to_s ⇒ String
Returns human readable representation (e.g. “FL045” or “1350 ft QNH”).
40 41 42 |
# File 'lib/aixm/z.rb', line 40 def to_s qne? ? "FL%03i" % alt : [alt, unit, code.upcase].join(' ') end |
#unit ⇒ Symbol
Returns unit - either :fl
(flight level) or :ft
(feet).
74 75 76 |
# File 'lib/aixm/z.rb', line 74 def unit qne? ? :fl : :ft end |
#zero? ⇒ Boolean
Returns whether height, elevation or altitude is zero.
22 |
# File 'lib/aixm/z.rb', line 22 def_delegator :@alt, :zero? |