Class: Bones::RPC::Adapter::JSON::Unpacker

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

Overview

I apologize for how nasty this unpacker is; Oj or Yajl would be better fits

Constant Summary collapse

ARRAY_START =
'['.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Unpacker

Returns a new instance of Unpacker.



42
43
44
# File 'lib/bones/rpc/adapter/json.rb', line 42

def initialize(data)
  @buffer = Bones::RPC::Parser::Buffer.new(data)
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



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

def buffer
  @buffer
end

Instance Method Details

#readObject



46
47
48
49
50
51
52
# File 'lib/bones/rpc/adapter/json.rb', line 46

def read
  if skip_to_array_start
    unpack_stream("", buffer.pos)
  else
    nil
  end
end