Class: Bones::RPC::Adapter::Erlang::Packer

Inherits:
Object
  • Object
show all
Defined in:
lib/bones/rpc/adapter/erlang.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer = "") ⇒ Packer

Returns a new instance of Packer.



40
41
42
# File 'lib/bones/rpc/adapter/erlang.rb', line 40

def initialize(buffer = "")
  @buffer = buffer
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



38
39
40
# File 'lib/bones/rpc/adapter/erlang.rb', line 38

def buffer
  @buffer
end

Instance Method Details

#write(term) ⇒ Object



44
45
46
47
48
49
# File 'lib/bones/rpc/adapter/erlang.rb', line 44

def write(term)
  binary = ::Erlang.term_to_binary(term)
  head, = binary[0].unpack('C')
  data = binary[1..-1]
  Adapter.write_ext(head, data, buffer)
end