module Koota::Encode

Encodes stuff!

Public Instance Methods

short(num) click to toggle source
# File lib/koota/encode.rb, line 8
def short(num)
  raise ArgumentError, 'number is too large' if num > 0xFFFF

  [(num & 0xFF00) >> 8, num & 0x00FF]
end
utf8(char) click to toggle source
# File lib/koota/encode.rb, line 14
def utf8(char)
  raise ArgumentError, 'empty string given' if char.empty?
  raise ArgumentError, 'expected one-char string' unless char.length == 1

  char.bytes
end