Class: SNMP::VarBind

### Home Classes Methods

### In Files

- lib/snmp/varbind.rb

### Parent

Object

### Methods

- ::decode
- ::decode_value
- ::new
- #asn1_type
- #each
- #encode
- #to_s
- #to_varbind
- #with_mib

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- SNMP
- SNMP::BER
- SNMP::Counter32
- SNMP::Counter64
- SNMP::EndOfMibView
- SNMP::Gauge32
- SNMP::GetBulkRequest
- SNMP::GetNextRequest
- SNMP::GetRequest
- SNMP::InformRequest
- SNMP::Integer
- SNMP::Integer32
- SNMP::InvalidErrorStatus
- SNMP::InvalidGenericTrap
- SNMP::InvalidIpAddress
- SNMP::InvalidPduTag
- SNMP::InvalidTrapVarbind
- SNMP::IpAddress
- SNMP::MIB
- SNMP::MIB::ModuleNotLoadedError
- SNMP::Manager
- SNMP::Manager::Config
- SNMP::Message
- SNMP::NoSuchInstance
- SNMP::NoSuchObject
- SNMP::Null
- SNMP::ObjectId
- SNMP::ObjectName
- SNMP::OctetString
- SNMP::Opaque
- SNMP::PDU
- SNMP::ParseError
- SNMP::RequestId
- SNMP::RequestTimeout
- SNMP::Response
- SNMP::SNMPv1_Trap
- SNMP::SNMPv2_Trap
- SNMP::SetRequest
- SNMP::TimeTicks
- SNMP::TrapListener
- SNMP::TrapListener::Config
- SNMP::UDPServerTransport
- SNMP::UDPTransport
- SNMP::Unsigned32
- SNMP::UnsignedInteger
- SNMP::UnsupportedPduTag
- SNMP::UnsupportedValueTag
- SNMP::UnsupportedVersion
- SNMP::VarBind
- SNMP::VarBindList
- Fixnum
- Object

No matching classes.

# 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() 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.