module MessagePack::Inspect::JSONLStreamer

Public Class Methods

object(io, depth, index) { || ... } click to toggle source
# File lib/msgpack/inspect/streamer.rb, line 255
def self.object(io, depth, index)
  if depth > 1 && index > 0
    io.print ","
  end
  retval = yield
  io.print "}"
  io.puts "" if depth == 1
  retval
end
objects(io, depth) { || ... } click to toggle source
# File lib/msgpack/inspect/streamer.rb, line 251
def self.objects(io, depth)
  yield
end

Public Instance Methods

attributes(io) click to toggle source
Calls superclass method
# File lib/msgpack/inspect/streamer.rb, line 290
def attributes(io)
  write(:format, :header)

  super

  write(:error) if @error

  case @format
  when :fixint, :uint8, :uint16, :uint32, :uint64, :int8, :int16, :int32, :int64
    write(:data, :value)
  when :fixmap, :map16, :map32
    write(:length)
  when :fixarray, :array16, :array32
    write(:length)
  when :fixstr, :str8, :str16, :str32
    write(:length, :data, :value)
  when :nil
    write(:data, :value)
  when :false
    write(:data, :value)
  when :true
    write(:data, :value)
  when :bin8, :bin16, :bin32
    write(:length, :data, :value)
  when :ext8, :ext16, :ext32, :fixext1, :fixext2, :fixext4, :fixext8, :fixext16
    if @value
      write(:exttype, :length, :data, :value)
    else
      write(:exttype, :length, :data)
    end
  when :float32, :float64
    write(:data, :value)
  when :never_used
    write(:data)
  end
end
element_key() click to toggle source
Calls superclass method
# File lib/msgpack/inspect/streamer.rb, line 339
def element_key
  if @first_kv_pair
    @first_kv_pair = false
  else
    @io.print ","
  end
  @io.print  %!{"key":!
  super
end
element_value() click to toggle source
Calls superclass method
# File lib/msgpack/inspect/streamer.rb, line 349
def element_value
  @io.print  %!,"value":!
  super
  @io.print %!}!
end
elements(&block) click to toggle source
Calls superclass method
# File lib/msgpack/inspect/streamer.rb, line 327
def elements(&block)
  @io.print ","
  if @length == 0
    @io.print %!"children":[]!
    return
  end

  @io.print %!"children":[!
  super
  @io.print %!]!
end
write(*attrs) click to toggle source
# File lib/msgpack/inspect/streamer.rb, line 265
def write(*attrs)
  attrs.each do |attr|
    @io.print "," unless @first_obj
    case attr
    when :format
      @io.print %!{"format":"#{@format.to_s}"!
    when :header
      @io.print %!"header":"0x#{hex(@header)}"!
    when :data
      @io.print %!"data":"0x#{@data}"!
    when :value
      if @value.nil?
        @io.print %!"value":null!
      else
        @io.print %!"value":#{@value.inspect}!
      end
    when :length
      @io.print %!"length":#{@length}!
    when :exttype
      @io.print %!"exttype":#{@exttype}!
    end
    @first_obj = false
  end
end