Class: NetCrawl::SNMP::VBHash
- Inherits:
-
Hash
- Object
- Hash
- NetCrawl::SNMP::VBHash
- Defined in:
- lib/netcrawl/snmp.rb
Overview
Hash with some helper methods to easier work with VarBinds
Instance Method Summary collapse
-
#[](*args) ⇒ SNMP::VarBind
Matching element.
-
#by_oid(*oid) ⇒ VBHash
Oids which start with param oid.
-
#by_partial(*args) ⇒ SNMP::VarBind
Matching element.
- #org_bracket ⇒ Object
Instance Method Details
#[](*args) ⇒ SNMP::VarBind
Returns matching element.
105 106 107 |
# File 'lib/netcrawl/snmp.rb', line 105 def [] *args org_bracket arg_to_oid(*args) end |
#by_oid(*oid) ⇒ VBHash
Returns oids which start with param oid.
80 81 82 83 84 85 86 87 |
# 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) ⇒ SNMP::VarBind
Returns matching element.
91 92 93 94 95 96 97 98 99 100 101 |
# 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 |
#org_bracket ⇒ Object
75 |
# File 'lib/netcrawl/snmp.rb', line 75 alias :org_bracket :[] |