Class: AIXM::F

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


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

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

Instance Attribute Details

#freqFloat

Returns frequency

Returns:

  • (Float)

    frequency


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

def freq
  @freq
end

#unitSymbol

Returns unit (see UNITS)

Returns:

  • (Symbol)

    unit (see UNITS)


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

def unit
  @unit
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Returns:

  • (Boolean)

See Also:

  • Object#==

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

Returns whether this frequency is part of a frequency band

Returns:

  • (Boolean)

    whether this frequency is part of a frequency band


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

#hashInteger

Returns:

  • (Integer)

See Also:

  • Object#hash

63
64
65
# File 'lib/aixm/f.rb', line 63

def hash
  to_s.hash
end

#inspectString

Returns:

  • (String)

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

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


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

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

#zero?Boolean

Returns whether frequency is zero

Returns:

  • (Boolean)

    whether frequency is zero


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

def_delegator :@freq, :zero?