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.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/snmp/varbind.rb', line 30 def initialize(varbind_list=[]) super() 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 |
Class Method Details
.decode(data) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/snmp/varbind.rb', line 20 def self.decode(data) list = VarBindList.new varbind_data, remainder = decode_sequence(data) while varbind_data != "" varbind, varbind_data = VarBind.decode(varbind_data) list << varbind end return list, remainder end |
Instance Method Details
#asn1_type ⇒ Object
41 42 43 |
# File 'lib/snmp/varbind.rb', line 41 def asn1_type "VarBindList" end |
#encode ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/snmp/varbind.rb', line 45 def encode varbind_data = "" self.each do |varbind| varbind_data << varbind.encode end encode_sequence(varbind_data) end |