Class: CBOR::Sequence

Inherits:
Struct
  • Object
show all
Defined in:
lib/cbor-pure.rb,
lib/cbor-diagnostic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#elementsObject

Returns the value of attribute elements

Returns:

  • (Object)

    the current value of elements



92
93
94
# File 'lib/cbor-pure.rb', line 92

def elements
  @elements
end

Instance Method Details

#cbor_diagnostic(options = {}) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/cbor-diagnostic.rb', line 152

def cbor_diagnostic(options = {})
  if elements == []
    "/ empty CBOR sequence /"
  else
    indent, _indent2, indented_options = cbor__indent_helper(options)
    pieces = elements.map{ |el|
      el.cbor_diagnostic(indented_options)
    }
    one_line = pieces.join(", ")
    if !(wrap = options[:wrap]) || one_line.length + indent.length < wrap # XXX
      one_line
    else
      "#{pieces.join(",\n#{indent}")}#{",\n" if options[:terminator]}"
    end
  end
end

#to_cborseqObject



97
98
99
# File 'lib/cbor-pure.rb', line 97

def to_cborseq
  CBOR.encode_seq(elements)
end

#to_sObject Also known as: inspect



93
94
95
# File 'lib/cbor-pure.rb', line 93

def to_s
  elements.map(&:to_s).join(", ")
end