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 ⇒ Float
Frequency.
-
#unit ⇒ Symbol
Unit (see UNITS).
Instance Method Summary collapse
- #==(other) ⇒ Boolean (also: #eql?)
-
#between?(lower_freq, upper_freq, unit) ⇒ Boolean
Whether this frequency is part of a frequency band.
- #hash ⇒ Integer
-
#initialize(freq, unit) ⇒ F
constructor
A new instance of F.
- #inspect ⇒ String
-
#to_s ⇒ String
Human readable representation (e.g. “123.35 mhz”).
-
#zero? ⇒ Boolean
Whether frequency is zero.
Constructor Details
#initialize(freq, unit) ⇒ F
24 25 26 |
# File 'lib/aixm/f.rb', line 24 def initialize(freq, unit) self.freq, self.unit = freq, unit end |
Instance Attribute Details
#freq ⇒ Float
19 20 21 |
# File 'lib/aixm/f.rb', line 19 def freq @freq end |
#unit ⇒ Symbol
22 23 24 |
# File 'lib/aixm/f.rb', line 22 def unit @unit end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
56 57 58 |
# File 'lib/aixm/f.rb', line 56 def ==(other) self.class === other && freq == other.freq && unit == other.unit end |
#between?(lower_freq, upper_freq, unit) ⇒ Boolean
50 51 52 |
# File 'lib/aixm/f.rb', line 50 def between?(lower_freq, upper_freq, unit) freq.between?(lower_freq, upper_freq) && self.unit == unit end |
#hash ⇒ Integer
63 64 65 |
# File 'lib/aixm/f.rb', line 63 def hash to_s.hash end |
#inspect ⇒ String
29 30 31 |
# File 'lib/aixm/f.rb', line 29 def inspect %Q(#<#{self.class} #{to_s}>) end |
#to_s ⇒ String
34 35 36 |
# File 'lib/aixm/f.rb', line 34 def to_s [freq, unit].join(' ') end |
#zero? ⇒ Boolean
16 |
# File 'lib/aixm/f.rb', line 16 def_delegator :@freq, :zero? |