| Class | SNMP::VarBind |
| In: |
lib/snmp/varbind.rb
|
| Parent: | Object |
| ValueDecoderMap | = | { INTEGER_TAG => Integer, OCTET_STRING_TAG => OctetString, NULL_TAG => Null, OBJECT_IDENTIFIER_TAG => ObjectId, IpAddress_TAG => IpAddress, Counter32_TAG => Counter32, Gauge32_TAG => Gauge32, # note Gauge32 tag same as Unsigned32 TimeTicks_TAG => TimeTicks, Opaque_TAG => Opaque, Counter64_TAG => Counter64, NoSuchObject_TAG => NoSuchObject, NoSuchInstance_TAG => NoSuchInstance, EndOfMibView_TAG => EndOfMibView |
| name | -> | oid |
| name | [RW] | |
| value | [RW] |
# File lib/snmp/varbind.rb, line 505 def decode(data) 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), remaining_varbind_data end
# File lib/snmp/varbind.rb, line 530 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 542 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 567 def encode data = encode_object_id(@name) << value.encode encode_sequence(data) end