Module: CoRE::CoAP::Types
- Included in:
- Options
- Defined in:
- lib/core/coap/types.rb
Instance Method Summary collapse
-
#o256_many(min, max) ⇒ Object
Unused, for now.
-
#o256_once(min, max, default = nil) ⇒ Object
Token-style, goedelized in o256.
-
#opaq_many(min, max) ⇒ Object
Any other opaque byte sequence (many).
-
#opaq_once(min, max, default = nil) ⇒ Object
Any other opaque byte sequence (once).
-
#presence_once ⇒ Object
We only care about presence or absence, always empty.
- #str_many(min, max) ⇒ Object
-
#str_once(min, max, default = nil) ⇒ Object
Same, but interpreted as UTF-8.
- #uint_many(min, max) ⇒ Object
-
#uint_once(min, max, default = nil) ⇒ Object
vlb as in core-coap Annex A.
Instance Method Details
#o256_many(min, max) ⇒ Object
Unused, for now.
21 22 23 24 25 26 |
# File 'lib/core/coap/types.rb', line 21 def o256_many(min, max) [nil, (min..max), true, ->(a) { a.map{ |x| CoAP.o256_decode(x)} }, ->(v) { Array(v).map{ |x| CoAP.o256_encode(x)} } ] end |
#o256_once(min, max, default = nil) ⇒ Object
Token-style, goedelized in o256.
13 14 15 16 17 18 |
# File 'lib/core/coap/types.rb', line 13 def o256_once(min, max, default = nil) [default, (min..max), false, ->(a) { CoAP.o256_decode(a[0]) }, ->(v) { v == default ? [] : [CoAP.o256_encode(v)] } ] end |
#opaq_many(min, max) ⇒ Object
Any other opaque byte sequence (many).
52 53 54 |
# File 'lib/core/coap/types.rb', line 52 def opaq_many(min, max) [nil, (min..max), true, ->(a) { a }, ->(v) { Array(v) }] end |
#opaq_once(min, max, default = nil) ⇒ Object
Any other opaque byte sequence (once).
44 45 46 47 48 49 |
# File 'lib/core/coap/types.rb', line 44 def opaq_once(min, max, default = nil) [default, (min..max), false, ->(a) { a[0] }, ->(v) { v == default ? [] : Array(v) } ] end |
#presence_once ⇒ Object
We only care about presence or absence, always empty.
8 9 10 |
# File 'lib/core/coap/types.rb', line 8 def presence_once [false, (0..0), false, ->(a) { true }, ->(v) { v ? [''] : []}] end |
#str_many(min, max) ⇒ Object
64 65 66 |
# File 'lib/core/coap/types.rb', line 64 def str_many(min, max) [nil, (min..max), true, ->(a) { a }, ->(v) { Array(v) }] end |
#str_once(min, max, default = nil) ⇒ Object
Same, but interpreted as UTF-8
57 58 59 60 61 62 |
# File 'lib/core/coap/types.rb', line 57 def str_once(min, max, default = nil) [default, (min..max), false, ->(a) { a[0] }, ->(v) { v == default ? [] : Array(v) } ] end |
#uint_many(min, max) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/core/coap/types.rb', line 36 def uint_many(min, max) [nil, (min..max), true, ->(a) { a.map{ |x| CoAP.vlb_decode(x)} }, ->(v) { Array(v).map{ |x| CoAP.vlb_encode(x)} } ] end |
#uint_once(min, max, default = nil) ⇒ Object
vlb as in core-coap Annex A
29 30 31 32 33 34 |
# File 'lib/core/coap/types.rb', line 29 def uint_once(min, max, default = nil) [default, (min..max), false, ->(a) { CoAP.vlb_decode(a[0]) }, ->(v) { v == default ? [] : [CoAP.vlb_encode(v)] } ] end |