Class: SNMP::VarBindList
- Inherits:
-
Array
- Object
- Array
- SNMP::VarBindList
- Defined in:
- lib/snmp/varbind.rb
Class Method Summary collapse
Instance Method Summary collapse
- #asn1_type ⇒ Object
- #encode ⇒ Object
-
#initialize(varbind_list = []) ⇒ VarBindList
constructor
A new instance of VarBindList.
Constructor Details
#initialize(varbind_list = []) ⇒ VarBindList
Returns a new instance of VarBindList.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/snmp/varbind.rb', line 43 def initialize(varbind_list=[]) super() if varbind_list.respond_to? :to_str self << ObjectId.new(varbind_list.to_str).to_varbind elsif varbind_list.respond_to? :to_varbind self << varbind_list.to_varbind else varbind_list.each do |item| if item.respond_to? :to_str self << ObjectId.new(item.to_str).to_varbind else self << item.to_varbind end end end end |
Class Method Details
.decode(data, mib = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/snmp/varbind.rb', line 33 def self.decode(data, mib=nil) list = VarBindList.new varbind_data, remainder = decode_sequence(data) while varbind_data != "" varbind, varbind_data = VarBind.decode(varbind_data, mib) list << varbind end return list, remainder end |
Instance Method Details
#asn1_type ⇒ Object
60 61 62 |
# File 'lib/snmp/varbind.rb', line 60 def asn1_type "VarBindList" end |
#encode ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/snmp/varbind.rb', line 64 def encode varbind_data = "" self.each do |varbind| varbind_data << varbind.encode end encode_sequence(varbind_data) end |