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
2 3 4 |
# File 'lib/cbor-diag-support.rb', line 2 def end |
#value ⇒ Object
Returns the value of attribute value
2 3 4 |
# File 'lib/cbor-diag-support.rb', line 2 def value @value end |
Class Method Details
.from_number(n, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cbor-diag-support.rb', line 9 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
24 25 26 27 28 29 30 |
# File 'lib/cbor-diag-support.rb', line 24 def cbor_diagnostic(opts = {}) ret = value.cbor_diagnostic(opts) if ei = [:ei] ret << "_#{ei}" end ret end |
#inspect ⇒ Object
6 7 8 |
# File 'lib/cbor-diag-support.rb', line 6 def inspect "#<CBOR::Box #{self.class} value=#{value.inspect}, options=#{options.inspect}>" end |
#to_cbor ⇒ Object
21 22 23 |
# File 'lib/cbor-diag-support.rb', line 21 def to_cbor CBOR.encode(value) end |
#to_s ⇒ Object
3 4 5 |
# File 'lib/cbor-diag-support.rb', line 3 def to_s value.to_s end |