module Erlang::ETF::Term

See [`erts/emulator/beam/external.h`]

[`erts/emulator/beam/external.h`]: github.com/erlang/otp/blob/master/erts/emulator/beam/external.h

Constants

ATOM_CACHE_REF
ATOM_EXT
ATOM_INTERNAL_REF2
ATOM_INTERNAL_REF3
ATOM_UTF8_EXT
BINARY_ENCODING
BINARY_EXT
BINARY_INTERNAL_REF
BIT_BINARY_EXT
BIT_BINARY_INTERNAL_REF
COMPRESSED
DIST_HEADER
DOUBLE
DOUBLEBE
DOUBLELE
ERLANG_MAGIC_BYTE
EXPORT_EXT
FLOAT_EXT
FUN_EXT
INT128
INT128BE
INT128LE
INT16
INT16BE
INT16LE
INT32
INT32BE
INT32LE
INT64
INT64BE
INT64LE
INT8
INTEGER_EXT
LARGE_BIG_EXT
LARGE_TUPLE_EXT
LIST_EXT
MAP_EXT
NEW_FLOAT_EXT
NEW_FUN_EXT
NEW_REFERENCE_EXT
NIL_EXT
PID_EXT
PORT_EXT
REFERENCE_EXT
SINGLE
SINGLEBE
SINGLELE
SMALL_ATOM_EXT
SMALL_ATOM_UTF8_EXT
SMALL_BIG_EXT
SMALL_INTEGER_EXT
SMALL_TUPLE_EXT
STRING_EXT
UINT128
UINT128BE
UINT128LE
UINT16
UINT16BE
UINT16LE
UINT32
UINT32BE
UINT32LE
UINT64
UINT64BE
UINT64LE
UINT8

Public Class Methods

binary_encoding(string) click to toggle source
# File lib/erlang/etf/term.rb, line 102
def self.binary_encoding(string)
  string = string.dup if string.frozen?
  string = string.force_encoding(BINARY_ENCODING)
  return string
end

Private Class Methods

included(base) click to toggle source

Extends the including class with ClassMethods.

@param [Class] subclass the inheriting class

Calls superclass method
# File lib/erlang/etf/term.rb, line 84
def included(base)
  super
  # base.send(:include, ::Binary::Protocol)
  base.send(:include, Erlang::Immutable)
  base.extend ClassMethods
  base.send(:include, ::Comparable)
  base.class_eval do
    attr_reader :term
    alias :to_erlang :term
    memoize :erlang_external_type
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/erlang/etf/term.rb, line 131
def <=>(other)
  return Erlang.compare(self, other)
end
eql?(other) click to toggle source
# File lib/erlang/etf/term.rb, line 127
def eql?(other)
  return @term.eql?(other)
end
erlang_external_type() click to toggle source
# File lib/erlang/etf/term.rb, line 108
def erlang_external_type
  type = self.class.name.split('::').last.dup
  type.gsub!('::', '/')
  type.gsub!(/(?:([A-Za-z\d])|^)(UTF8)(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
  type.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
  type.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
  type.tr!("-", "_")
  type.downcase!
  return type.intern
end
hash() click to toggle source
# File lib/erlang/etf/term.rb, line 123
def hash
  return @term.hash
end
inspect() click to toggle source
# File lib/erlang/etf/term.rb, line 119
def inspect
  return "#{self.class.name}[#{term.inspect}]"
end
to_erlang_etf() click to toggle source
# File lib/erlang/etf/term.rb, line 135
def to_erlang_etf
  return self
end