class SNMP::VarBind
Constants
- ValueDecoderMap
Attributes
Public Class Methods
Source
# File lib/snmp/varbind.rb, line 561 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
Source
# File lib/snmp/varbind.rb, line 586 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
Source
# File lib/snmp/varbind.rb, line 598 def initialize(name, value=Null) if name.kind_of? ObjectId @name = name else @name = ObjectName.new(name) end @value = value end
Public Instance Methods
Source
# File lib/snmp/varbind.rb, line 632 def encode data = encode_object_id(@name) << value.encode encode_sequence(data) end
Source
# File lib/snmp/varbind.rb, line 624 def to_s "[name=#{@name.to_s}, value=#{@value.to_s} (#{@value.asn1_type})]" end
Source
# File lib/snmp/varbind.rb, line 610 def with_mib(mib) @name.with_mib(mib) if @name @value.with_mib(mib) if @value.respond_to? :with_mib self end
Adds MIB
information to this varbind for use with to_s.