Class: AIXM::F

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(freq, unit) ⇒ F

Returns a new instance of F


18
19
20
# File 'lib/aixm/f.rb', line 18

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

Instance Attribute Details

#freqFloat

Returns frequency

Returns:

  • (Float)

    frequency


13
14
15
# File 'lib/aixm/f.rb', line 13

def freq
  @freq
end

#unitSymbol

Returns unit (see UNITS)

Returns:

  • (Symbol)

    unit (see UNITS)


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

def unit
  @unit
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)

44
45
46
# File 'lib/aixm/f.rb', line 44

def ==(other)
  other.is_a?(self.class) && freq == other.freq && unit == other.unit
end

#between?(lower_freq, upper_freq, unit) ⇒ Boolean

Returns whether this frequency is part of a frequency band

Returns:

  • (Boolean)

    whether this frequency is part of a frequency band


49
50
51
# File 'lib/aixm/f.rb', line 49

def between?(lower_freq, upper_freq, unit)
  freq.between?(lower_freq, upper_freq) && self.unit == unit
end

#inspectString

Returns:

  • (String)

23
24
25
# File 'lib/aixm/f.rb', line 23

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”)


28
29
30
# File 'lib/aixm/f.rb', line 28

def to_s
  [freq, unit].join(' ')
end