class SNMP::VarBind
Constants
- ValueDecoderMap
Attributes
name[RW]
oid[RW]
value[RW]
Public Class Methods
decode(data, mib=nil)
click to toggle source
# 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
decode_value(data)
click to toggle source
# 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
new(name, value=Null)
click to toggle source
# 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
Public Instance Methods
asn1_type()
click to toggle source
# File lib/snmp/varbind.rb, line 582 def asn1_type "VarBind" end
each() { |self| ... }
click to toggle source
# File lib/snmp/varbind.rb, line 594 def each yield self end
encode()
click to toggle source
# File lib/snmp/varbind.rb, line 598 def encode data = encode_object_id(@name) << value.encode encode_sequence(data) end
to_s()
click to toggle source
# File lib/snmp/varbind.rb, line 590 def to_s "[name=#{@name.to_s}, value=#{@value.to_s} (#{@value.asn1_type})]" end
to_varbind()
click to toggle source
# File lib/snmp/varbind.rb, line 586 def to_varbind self end
with_mib(mib)
click to toggle source
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