class Erlang::OtpErlangAtom

Attributes

value[R]

Public Class Methods

new(value) click to toggle source
# File lib/erlang.rb, line 36
def initialize(value)
    @value = value
end

Public Instance Methods

==(other) click to toggle source
# File lib/erlang.rb, line 78
def ==(other)
    return binary == other.binary
end
Also aliased as: eql?
binary() click to toggle source
# File lib/erlang.rb, line 40
def binary
    if @value.kind_of?(Integer)
        return "#{TAG_ATOM_CACHE_REF.chr}#{@value.chr}"
    elsif @value.kind_of?(String)
        length = @value.bytesize
        if @value.encoding.name == 'UTF-8'
            if length <= 255
                return "#{TAG_SMALL_ATOM_UTF8_EXT.chr}#{length.chr}" \
                       "#{@value}"
            elsif length <= 65535
                length_packed = [length].pack('n')
                return "#{TAG_ATOM_UTF8_EXT.chr}#{length_packed}" \
                       "#{@value}"
            else
                raise OutputException, 'uint16 overflow', caller
            end
        else
            # deprecated
            # (not used in Erlang/OTP 26, i.e., minor_version 2)
            if length <= 255
                return "#{TAG_SMALL_ATOM_EXT.chr}#{length.chr}#{@value}"
            elsif length <= 65535
                length_packed = [length].pack('n')
                return "#{TAG_ATOM_EXT.chr}#{length_packed}#{@value}"
            else
                raise OutputException, 'uint16 overflow', caller
            end
        end
    else
        raise OutputException, 'unknown atom type', caller
    end
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/erlang.rb, line 75
def hash
    return binary.hash
end
to_s() click to toggle source
# File lib/erlang.rb, line 72
def to_s
    return "#{self.class.name}('#{@value.to_s}')"
end