class AIXM::F
Radio frequency for communication, navigation and so forth.
@example
AIXM.f(123.35, :mhz)
Constants
- UNITS
Attributes
freq[R]
@return [Float] frequency
unit[R]
@return [Symbol] unit (see {UNITS})
Public Class Methods
new(freq, unit)
click to toggle source
# File lib/aixm/f.rb 24 def initialize(freq, unit) 25 self.freq, self.unit = freq, unit 26 end
Public Instance Methods
==(other)
click to toggle source
@see Object#== @return [Boolean]
# File lib/aixm/f.rb 56 def ==(other) 57 self.class === other && freq == other.freq && unit == other.unit 58 end
Also aliased as: eql?
between?(lower_freq, upper_freq, unit)
click to toggle source
@return [Boolean] whether this frequency is part of a frequency band
# File lib/aixm/f.rb 50 def between?(lower_freq, upper_freq, unit) 51 freq.between?(lower_freq, upper_freq) && self.unit == unit 52 end
freq=(value)
click to toggle source
# File lib/aixm/f.rb 38 def freq=(value) 39 fail(ArgumentError, "invalid freq") unless value.is_a? Numeric 40 @freq = value.to_f 41 end
hash()
click to toggle source
@see Object#hash @return [Integer]
# File lib/aixm/f.rb 63 def hash 64 to_s.hash 65 end
inspect()
click to toggle source
@return [String]
# File lib/aixm/f.rb 29 def inspect 30 %Q(#<#{self.class} #{to_s}>) 31 end
to_s()
click to toggle source
@return [String] human readable representation (e.g. “123.35 mhz”)
# File lib/aixm/f.rb 34 def to_s 35 [freq, unit].join(' ') 36 end
unit=(value)
click to toggle source
# File lib/aixm/f.rb 43 def unit=(value) 44 fail(ArgumentError, "invalid unit") unless value.respond_to? :to_sym 45 @unit = value.to_sym.downcase 46 fail(ArgumentError, "invalid unit") unless UNITS.include? @unit 47 end