Method: NMEAPlus::Message::AIS::VDM#_dearmor6b

Defined in:
lib/nmea_plus/message/ais/vdm.rb

#_dearmor6b(c, len = 6) ⇒ String

perform the 6-bit to 8-bit conversion defined in the spec

Parameters:

  • c (String)

    a character

  • len (Integer) (defaults to: 6)

    The number of bits to consider

Returns:

  • (String)

    a binary encoded string

[View source]

115
116
117
118
119
# File 'lib/nmea_plus/message/ais/vdm.rb', line 115

def _dearmor6b(c, len = 6)
  val = c.ord
  ret = val - (val >= 96 ? 56 : 48)  # Mapped to 2 separate contiguous blocks of ascii, so choose which
  ret.to_s(2).rjust(6, "0")[0..(len - 1)]
end