Class: AIXM::F
Overview
Radio frequency for communication, navigation and so forth.
Constant Summary collapse
- UNITS =
i(ghz mhz khz).freeze
Instance Attribute Summary collapse
-
#freq ⇒ Object
Frequency.
-
#unit ⇒ Object
Unit.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#between?(lower_freq, upper_freq, unit) ⇒ Boolean
Whether this frequency is part of a frequency band.
-
#initialize(freq, unit) ⇒ F
constructor
See the overview for examples.
- #inspect ⇒ String
-
#to_s ⇒ String
Human readable representation (e.g. “123.35 mhz”).
-
#voice? ⇒ Boolean
Whether this frequency is part of the voice airband for civil aviation using
AIXM.config.voice_channel_separation
. -
#voice_emergency? ⇒ Boolean
Whether this frequency is for emergencies only.
-
#zero? ⇒ Boolean
Whether frequency is zero.
Methods included from Concerns::HashEquality
Constructor Details
Instance Attribute Details
#freq ⇒ Float #freq=(value) ⇒ Object
Frequency
25 26 27 |
# File 'lib/aixm/f.rb', line 25 def freq @freq end |
#unit ⇒ Symbol #unit=(value) ⇒ Object
Unit
33 34 35 |
# File 'lib/aixm/f.rb', line 33 def unit @unit end |
Instance Method Details
#==(other) ⇒ Object
69 70 71 |
# File 'lib/aixm/f.rb', line 69 def ==(other) self.class === other && freq == other.freq && unit == other.unit end |
#between?(lower_freq, upper_freq, unit) ⇒ Boolean
Whether this frequency is part of a frequency band.
64 65 66 |
# File 'lib/aixm/f.rb', line 64 def between?(lower_freq, upper_freq, unit) freq.between?(lower_freq, upper_freq) && self.unit == unit end |
#inspect ⇒ String
41 42 43 |
# File 'lib/aixm/f.rb', line 41 def inspect %Q(#<#{self.class} #{to_s}>) end |
#to_s ⇒ String
Returns human readable representation (e.g. “123.35 mhz”).
46 47 48 |
# File 'lib/aixm/f.rb', line 46 def to_s [freq, unit].join(' '.freeze) end |
#voice? ⇒ Boolean
Whether this frequency is part of the voice airband for civil aviation using AIXM.config.voice_channel_separation
.
77 78 79 80 81 82 83 84 85 |
# File 'lib/aixm/f.rb', line 77 def voice? return false unless unit == :mhz case AIXM.config.voice_channel_separation when 25 then voice_25? when 833 then voice_833? when :any then voice_25? || voice_833? else fail(ArgumentError, "unknown voice channel separation") end end |
#voice_emergency? ⇒ Boolean
Whether this frequency is for emergencies only.
90 91 92 |
# File 'lib/aixm/f.rb', line 90 def voice_emergency? self == AIXM::EMERGENCY end |
#zero? ⇒ Boolean
Returns whether frequency is zero.
17 |
# File 'lib/aixm/f.rb', line 17 def_delegator :@freq, :zero? |