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 ⇒ Object
Altitude or elevation value.
-
#code ⇒ Object
Q code.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#ground? ⇒ Boolean
Whether ground level.
-
#initialize(alt, code) ⇒ Z
constructor
See the overview for examples.
- #inspect ⇒ String
-
#qfe? ⇒ Boolean
Whether QFE, QNH or QNE.
-
#qne? ⇒ Boolean
Whether QFE, QNH or QNE.
-
#qnh? ⇒ Boolean
Whether QFE, QNH or QNE.
-
#to_s ⇒ String
Human readable representation (e.g. “FL045” or “1350 ft QNH”).
-
#unit ⇒ Symbol
Unit.
- #zero? ⇒ Boolean
Methods included from Concerns::HashEquality
Constructor Details
Instance Attribute Details
#alt ⇒ Integer #alt=(value) ⇒ Object
Altitude or elevation value.
33 34 35 |
# File 'lib/aixm/z.rb', line 33 def alt @alt end |
#code ⇒ Symbol #code=(value) ⇒ Object
Q code
43 44 45 |
# File 'lib/aixm/z.rb', line 43 def code @code end |
Instance Method Details
#==(other) ⇒ Object
101 102 103 |
# File 'lib/aixm/z.rb', line 101 def ==(other) self.class === other && alt == other.alt && code == other.code end |
#ground? ⇒ Boolean
Whether ground level
89 90 91 |
# File 'lib/aixm/z.rb', line 89 def ground? qfe? && @alt == 0 end |
#inspect ⇒ String
51 52 53 |
# File 'lib/aixm/z.rb', line 51 def inspect %Q(#<#{self.class} #{to_s}>) end |
#qfe? ⇒ Boolean
Whether QFE, QNH or QNE.
82 83 84 |
# File 'lib/aixm/z.rb', line 82 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#qne? ⇒ Boolean
Whether QFE, QNH or QNE.
82 83 84 |
# File 'lib/aixm/z.rb', line 82 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#qnh? ⇒ Boolean
Whether QFE, QNH or QNE.
82 83 84 |
# File 'lib/aixm/z.rb', line 82 CODES.each do |code| define_method(:"#{code}?") { @code == code } end |
#to_s ⇒ String
Returns human readable representation (e.g. “FL045” or “1350 ft QNH”).
56 57 58 |
# File 'lib/aixm/z.rb', line 56 def to_s qne? ? "FL%03i" % alt : [alt, unit, code.upcase].join(' '.freeze) end |
#unit ⇒ Symbol
Unit
96 97 98 |
# File 'lib/aixm/z.rb', line 96 def unit qne? ? :fl : :ft end |
#zero? ⇒ Boolean
25 |
# File 'lib/aixm/z.rb', line 25 def_delegator :@alt, :zero? |