Class: CBOR::Box
- Inherits:
-
Struct
- Object
- Struct
- CBOR::Box
- Defined in:
- lib/cbor-diag-support.rb
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_number(n, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cbor-diag-support.rb', line 15 def self.from_number(n, ={}) case n when Box n.class.new(n.value, n..merge()) when ::Integer Ibox.new(n, .dup) when ::Float Fbox.new(n, .dup) else raise ArgumentError, "cbor-diagnostic: can't box number from #{n.inspect}':\n" end end |
Instance Method Details
#cbor_diagnostic(opts = {}) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cbor-diag-support.rb', line 30 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
27 28 29 |
# File 'lib/cbor-diag-support.rb', line 27 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 |