Class: Array

Inherits:
Object show all
Defined in:
lib/cbor-diagnostic.rb

Instance Method Summary collapse

Instance Method Details

#cbor_diagnostic(options = {}) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cbor-diagnostic.rb', line 118

def cbor_diagnostic(options = {})
  indent, indent2, indented_options = cbor__indent_helper(options)
  pieces = map {|x| x.cbor_diagnostic(indented_options)}
  one_line = "[#{"_ " if cbor_stream?}#{pieces.join(", ")}]"
  if !(wrap = options[:wrap]) || pieces == [] || one_line.length + indent.length < wrap # XXX
    one_line
  else
    open, close = options[:terminator] ? ["\n#{indent2}", ",\n#{indent}"] : [" ", " "]
    "[#{"_" if cbor_stream?}#{open}#{pieces.join(",\n#{indent2}")}#{close}]"
  end
end