class Erlang::OtpErlangList

Attributes

improper[R]
value[R]

Public Class Methods

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

Public Instance Methods

==(other) click to toggle source
# File lib/erlang.rb, line 176
def ==(other)
    return binary == other.binary
end
Also aliased as: eql?
binary() click to toggle source
# File lib/erlang.rb, line 144
def binary
    if @value.kind_of?(Array)
        length = @value.length
        if length == 0
            return TAG_NIL_EXT.chr
        elsif length > 4294967295
            raise OutputException, 'uint32 overflow', caller
        elsif @improper
            length_packed = [length - 1].pack('N')
            list_packed = @value.map{ |element|
                Erlang::term_to_binary_(element)
            }.join
            return "#{TAG_LIST_EXT.chr}#{length_packed}#{list_packed}"
        else
            length_packed = [length].pack('N')
            list_packed = @value.map{ |element|
                Erlang::term_to_binary_(element)
            }.join
            return "#{TAG_LIST_EXT.chr}#{length_packed}" \
                   "#{list_packed}#{TAG_NIL_EXT.chr}"
        end
    else
        raise OutputException, 'unknown list type', caller
    end
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/erlang.rb, line 173
def hash
    return binary.hash
end
to_s() click to toggle source
# File lib/erlang.rb, line 169
def to_s
    return "#{self.class.name}" \
           "(#{@value.to_s},improper=#{@improper.to_s})"
end