class NetCrawl::SNMP::VBHash
Hash with some helper methods to easier work with VarBinds
Public Instance Methods
[](*args)
click to toggle source
@param [Array[String, Array)] key which you want, multiple arguments compiled into single key @return [SNMP::VarBind] matching element
# File lib/netcrawl/snmp.rb, line 105 def [] *args org_bracket arg_to_oid(*args) end
Also aliased as: org_bracket
by_oid(*oid)
click to toggle source
@param [Array(Strin, Array)] oid root oid under which you want all oids below it @return [VBHash] oids which start with param oid
# File lib/netcrawl/snmp.rb, line 80 def by_oid *oid oid = arg_to_oid(*oid) hash = select do |key, value| key[0..oid.size-1] == oid end newhash = VBHash.new newhash.merge hash end
by_partial(*args)
click to toggle source
@param [Array(String, Array)] args partial match 3.4.6 would match to 1.2.3.4.6.7.8 @return [SNMP::VarBind] matching element
# File lib/netcrawl/snmp.rb, line 91 def by_partial *args oid = arg_to_oid(*args) got = nil keys.each do |key| if key.each_cons(oid.size).find{|e|e==oid} got = self[key] break end end got end
Private Instance Methods
arg_to_oid(*args)
click to toggle source
# File lib/netcrawl/snmp.rb, line 111 def arg_to_oid *args key = [] args.each do |arg| if Array === arg key += arg.map{|e|e.to_i} elsif Fixnum === arg key << arg else key += arg.split('.').map{|e|e.to_i} end end key end