# File lib/snmp/varbind.rb, line 527 def decode(data, mib=nil) varbind_data, remaining_varbind_data = decode_sequence(data) name, remainder = decode_object_id(varbind_data) value, remainder = decode_value(remainder) assert_no_remainder(remainder) return VarBind.new(name, value).with_mib(mib), remaining_varbind_data end
# File lib/snmp/varbind.rb, line 552 def decode_value(data) value_tag, value_data, remainder = decode_tlv(data) decoder_class = ValueDecoderMap[value_tag] if decoder_class value = decoder_class.decode(value_data) else raise UnsupportedValueTag, value_tag.to_s end return value, remainder end
# File lib/snmp/varbind.rb, line 564 def initialize(name, value=Null) if name.kind_of? ObjectId @name = name else @name = ObjectName.new(name) end @value = value end
# File lib/snmp/varbind.rb, line 582 def asn1_type "VarBind" end
# File lib/snmp/varbind.rb, line 594 def each yield self end
# File lib/snmp/varbind.rb, line 598 def encode data = encode_object_id(@name) << value.encode encode_sequence(data) end
# File lib/snmp/varbind.rb, line 590 def to_s "[name=#{@name.to_s}, value=#{@value.to_s} (#{@value.asn1_type})]" end
# File lib/snmp/varbind.rb, line 586 def to_varbind self end
Adds MIB information to this varbind for use with to_s.
# File lib/snmp/varbind.rb, line 576 def with_mib(mib) @name.with_mib(mib) if @name @value.with_mib(mib) if @value.respond_to? :with_mib self end