Module: CBOR
- Defined in:
- lib/cbor-pure.rb,
lib/cbor-pretty.rb
Defined Under Namespace
Modules: CoreExt, Streaming
Classes: Break, Buffer, OutOfBytesError, Sequence, Simple, Tagged, Transform, Transform_j, Transform_jr
Constant Summary
collapse
- BREAK =
Break.new.freeze
- TAG_BIGNUM_BASE =
2
Class Method Summary
collapse
Class Method Details
.decode(s) ⇒ Object
112
113
114
|
# File 'lib/cbor-pure.rb', line 112
def self.decode(s)
Buffer.new(s).decode_item_final
end
|
.decode_seq(s) ⇒ Object
118
119
120
|
# File 'lib/cbor-pure.rb', line 118
def self.decode_seq(s)
Buffer.new(s).decode_items
end
|
.decode_with_rest(s) ⇒ Object
115
116
117
|
# File 'lib/cbor-pure.rb', line 115
def self.decode_with_rest(s)
Buffer.new(s).decode_item_with_rest
end
|
.encode(d) ⇒ Object
102
103
104
|
# File 'lib/cbor-pure.rb', line 102
def self.encode(d)
Buffer.new.add(d).buffer
end
|
.encode_seq(ds) ⇒ Object
105
106
107
108
109
110
111
|
# File 'lib/cbor-pure.rb', line 105
def self.encode_seq(ds)
out = Buffer.new
ds.each do |d|
out.add(d)
end
out.buffer
end
|
.pretty(s, indent = 0, max_target = 40, warnings: nil) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/cbor-pretty.rb', line 26
def self.pretty(s, indent = 0, max_target = 40, warnings: nil)
b = Buffer.new(s)
warnings ||= s.cbor_warnings
b.warnings = warnings if warnings
b.pretty_item_final(indent, max_target)
end
|
.pretty_seq(s, indent = 0, max_target = 40, warnings: nil) ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/cbor-pretty.rb', line 33
def self.pretty_seq(s, indent = 0, max_target = 40, warnings: nil)
b = Buffer.new(s)
warnings ||= s.cbor_warnings
b.warnings = warnings if warnings
res = ''
while !b.empty?
res << b.pretty_item_final(indent, max_target, true)
end
res
end
|