Module: CoRE::CoAP::Utility

Included in:
CoRE::CoAP
Defined in:
lib/core/coap/utility.rb

Instance Method Summary collapse

Instance Method Details

#critical?(option) ⇒ Boolean


12
13
14
15
16
17
# File 'lib/core/coap/utility.rb', line 12

def critical?(option)
  if oi = CoAP::OPTIONS_I[option] # this is really an option name symbol
    option = oi[0]          # -> to option number
  end
  option.odd?
end

#empty_bufferObject


4
5
6
# File 'lib/core/coap/utility.rb', line 4

def empty_buffer
  String.new # Was: ''.encode(BIN)
end

#invert_into_hash(a) ⇒ Object


8
9
10
# File 'lib/core/coap/utility.rb', line 8

def invert_into_hash(a)
  a.each_with_index.each_with_object({}) { |k, h| h[k[0]] = k[1] if k[0] }
end

#no_cache_key?(option) ⇒ Boolean


26
27
28
29
30
31
# File 'lib/core/coap/utility.rb', line 26

def no_cache_key?(option)
  if oi = CoAP::OPTIONS_I[option] # this is really an option name symbol
    option = oi[0]          # -> to option number
  end
  option & 0x1e == 0x1c
end

#unsafe?(option) ⇒ Boolean


19
20
21
22
23
24
# File 'lib/core/coap/utility.rb', line 19

def unsafe?(option)
  if oi = CoAP::OPTIONS_I[option] # this is really an option name symbol
    option = oi[0]          # -> to option number
  end
  option & 2 == 2
end