Class: AIXM::F

Inherits:
Object show all
Extended by:
Forwardable
Includes:
Concerns::HashEquality
Defined in:
lib/aixm/f.rb

Overview

Radio frequency for communication, navigation and so forth.

Examples:

AIXM.f(123.35, :mhz)

Constant Summary collapse

UNITS =
%i(ghz mhz khz).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::HashEquality

#eql?, #hash

Constructor Details

#initialize(freq, unit) ⇒ F

See the overview for examples.



36
37
38
# File 'lib/aixm/f.rb', line 36

def initialize(freq, unit)
  self.freq, self.unit = freq, unit
end

Instance Attribute Details

#freqFloat #freq=(value) ⇒ Object

Frequency

Overloads:

  • #freqFloat

    Returns:

    • (Float)
  • #freq=(value) ⇒ Object

    Parameters:

    • value (Float)


25
26
27
# File 'lib/aixm/f.rb', line 25

def freq
  @freq
end

#unitSymbol #unit=(value) ⇒ Object

Unit

Overloads:

  • #unitSymbol

    Returns any of UNITS.

    Returns:

    • (Symbol)

      any of UNITS

  • #unit=(value) ⇒ Object

    Parameters:

    • value (Symbol)

      any of UNITS



33
34
35
# File 'lib/aixm/f.rb', line 33

def unit
  @unit
end

Instance Method Details

#==(other) ⇒ Object

See Also:

  • 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.

Returns:

  • (Boolean)


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

#inspectString

Returns:

  • (String)


41
42
43
# File 'lib/aixm/f.rb', line 41

def inspect
  %Q(#<#{self.class} #{to_s}>)
end

#to_sString

Returns human readable representation (e.g. “123.35 mhz”).

Returns:

  • (String)

    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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


90
91
92
# File 'lib/aixm/f.rb', line 90

def voice_emergency?
  self == AIXM::EMERGENCY
end

#zero?Boolean

Returns whether frequency is zero.

Returns:

  • (Boolean)

    whether frequency is zero



17
# File 'lib/aixm/f.rb', line 17

def_delegator :@freq, :zero?