Method: NETSNMP::PDU.build

Defined in:
lib/netsnmp/pdu.rb

.build(type, **args) ⇒ Object

factory method that abstracts initialization of the pdu types that the library supports.

Parameters:

  • type (Symbol)

    the type of pdu structure to build



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/netsnmp/pdu.rb', line 47

def build(type, **args)
  typ = case type
        when :get       then 0
        when :getnext   then 1
        #          when :getbulk   then 5
        when :set       then 3
        when :inform    then 6
        when :trap      then 7
        when :response  then 2
        when :report    then 8
        else raise Error, "#{type} is not supported as type"
        end
  new(type: typ, **args)
end