module TTTLS13::Refinements

Public Instance Methods

prefix_uint16_length() click to toggle source
# File lib/tttls1.3/utils.rb, line 48
def prefix_uint16_length
  length.to_uint16 + self
end
prefix_uint24_length() click to toggle source
# File lib/tttls1.3/utils.rb, line 52
def prefix_uint24_length
  length.to_uint24 + self
end
prefix_uint32_length() click to toggle source
# File lib/tttls1.3/utils.rb, line 56
def prefix_uint32_length
  length.to_uint32 + self
end
prefix_uint64_length() click to toggle source
# File lib/tttls1.3/utils.rb, line 60
def prefix_uint64_length
  length.to_uint64 + self
end
prefix_uint8_length() click to toggle source
# File lib/tttls1.3/utils.rb, line 44
def prefix_uint8_length
  length.to_uint8 + self
end
to_uint16() click to toggle source
# File lib/tttls1.3/utils.rb, line 14
def to_uint16
  raise Error::ErrorAlerts, :internal_error \
    if negative? || self >= (1 << 16)

  [self].pack('n')
end
to_uint24() click to toggle source
# File lib/tttls1.3/utils.rb, line 21
def to_uint24
  raise Error::ErrorAlerts, :internal_error \
    if negative? || self >= (1 << 24)

  [self].pack('N1')[1..]
end
to_uint32() click to toggle source
# File lib/tttls1.3/utils.rb, line 28
def to_uint32
  raise Error::ErrorAlerts, :internal_error \
    if negative? || self >= (1 << 32)

  [self].pack('N1')
end
to_uint64() click to toggle source
# File lib/tttls1.3/utils.rb, line 35
def to_uint64
  raise Error::ErrorAlerts, :internal_error \
    if negative? || self >= (1 << 64)

  [self >> 32, self].pack('N2')
end
to_uint8() click to toggle source
# File lib/tttls1.3/utils.rb, line 7
def to_uint8
  raise Error::ErrorAlerts, :internal_error \
    if negative? || self >= (1 << 8)

  chr
end