Class: CBOR::Box
- Inherits:
-
Struct
- Object
- Struct
- CBOR::Box
- Defined in:
- lib/cbor-diag-support.rb
Constant Summary collapse
- INTEGER_EI =
{ "i" => [23, 0], "0" => [0xFF, 1], "1" => [0xFFFF, 2], "2" => [0xFFFFFFFF, 4], "3" => [0xFFFFFFFFFFFFFFFF, 8] }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options
8 9 10 |
# File 'lib/cbor-diag-support.rb', line 8 def @options end |
#value ⇒ Object
Returns the value of attribute value
8 9 10 |
# File 'lib/cbor-diag-support.rb', line 8 def value @value end |
Class Method Details
.from_instance(n, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cbor-diag-support.rb', line 15 def self.from_instance(n, ={}) case n when Box n.class.new(n.value, n..merge()) when ::Integer Ibox.new(n, .dup) when ::Float Fbox.new(n, .dup) when ::String, ::Array, ::Hash, ::CBOR::Tagged Xbox.new(n, .dup) else raise ArgumentError, "cbor-diagnostic: can't box number from #{n.inspect}':\n" end end |
.make_head(ib, plusbytes, d) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cbor-diag-support.rb', line 37 def self.make_head(ib, plusbytes, d) case plusbytes when 0 [ib + d].pack("C") when 1 [ib + 24, d].pack("CC") when 2 [ib + 25, d].pack("Cn") when 4 [ib + 26, d].pack("CN") when 8 [ib + 27, d].pack("CQ>") else raise ArgumentError, "cbor-diagnostic: #{plusbytes} plusbytes when encoding head\n" end end |
Instance Method Details
#cbor_diagnostic(opts = {}) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/cbor-diag-support.rb', line 57 def cbor_diagnostic(opts = {}) ret = value.cbor_diagnostic(opts) if ei = [:ei] ret << "_#{ei}" end ret end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/cbor-diag-support.rb', line 12 def inspect "#<CBOR::Box #{self.class} value=#{value.inspect}, options=#{.inspect}>" end |
#to_cbor ⇒ Object
54 55 56 |
# File 'lib/cbor-diag-support.rb', line 54 def to_cbor CBOR.encode(value) end |
#to_s ⇒ Object
9 10 11 |
# File 'lib/cbor-diag-support.rb', line 9 def to_s value.to_s end |