Class: Hash
Instance Attribute Summary collapse
-
#cbor_entries ⇒ Object
Returns the value of attribute cbor_entries.
Class Method Summary collapse
Instance Method Summary collapse
- #cbor_diagnostic(options = {}) ⇒ Object
- #cbor_map_lost_warning ⇒ Object
- #cbor_map_push(key, value, entries) ⇒ Object
Instance Attribute Details
#cbor_entries ⇒ Object
Returns the value of attribute cbor_entries.
39 40 41 |
# File 'lib/cbor-pure.rb', line 39 def cbor_entries @cbor_entries end |
Class Method Details
.cbor_from_entries(entries) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/cbor-pure.rb', line 40 def self.cbor_from_entries(entries) h = Hash[entries] if h.size != entries.size # dupkeys found h.cbor_entries = entries end h end |
Instance Method Details
#cbor_diagnostic(options = {}) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/cbor-diagnostic.rb', line 132 def cbor_diagnostic( = {}) indent, indent2, = cbor__indent_helper() pieces = map {|x| x.map {|y| y.cbor_diagnostic()}.join(": ")} # XXX key/value split one_line = "{#{"_ " if cbor_stream?}#{pieces.join(", ")}#{cbor_map_lost_warning}}" if !(wrap = [:wrap]) || pieces == [] || one_line.length + indent.length < wrap # XXX one_line else open, close = [:terminator] ? ["\n#{indent2}", ",\n#{indent}"] : [" ", " "] "{#{"_" if cbor_stream?}#{open}#{pieces.join(",\n#{indent2}")}#{close}#{cbor_map_lost_warning}}" end end |
#cbor_map_lost_warning ⇒ Object
55 56 57 58 59 60 |
# File 'lib/cbor-pure.rb', line 55 def cbor_map_lost_warning if cbor_entries lost = cbor_entries.size - size " / #{lost} DUP KEY#{"S" if lost > 1} LOST / " end end |
#cbor_map_push(key, value, entries) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/cbor-pure.rb', line 47 def cbor_map_push(key, value, entries) entries << [key, value] n = size self[key] = value if n == size # key was overwritten self.cbor_entries = entries end end |