Module: Net::BER::Extensions::Fixnum

### Home Classes Methods

### In Files

- lib/net/ber/core_ext/fixnum.rb

### Methods

- #to_ber
- #to_ber_application
- #to_ber_enumerated
- #to_ber_length_encoding

### Files

- History.rdoc
- Manifest.txt

### Class/Module Index

Quicksearch

- Net
- Net::BER
- Net::BER::BERParser
- Net::BER::BerError
- Net::BER::BerIdentifiedArray
- Net::BER::BerIdentifiedNull
- Net::BER::BerIdentifiedOid
- Net::BER::BerIdentifiedString
- Net::BER::Extensions
- Net::BER::Extensions::Array
- Net::BER::Extensions::Bignum
- Net::BER::Extensions::FalseClass
- Net::BER::Extensions::Fixnum
- Net::BER::Extensions::String
- Net::BER::Extensions::TrueClass
- Net::LDAP
- Net::LDAP::Connection
- Net::LDAP::Connection::GetbyteForSSLSocket
- Net::LDAP::DN
- Net::LDAP::Dataset
- Net::LDAP::Entry
- Net::LDAP::Filter
- Net::LDAP::LdapControls
- Net::LDAP::LdapError
- Net::LDAP::PDU
- Net::LDAP::PDU::Error
- Net::LDAP::Password
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLSocket

No matching classes.

# Net::BER::Extensions::Fixnum

Ber extensions to the Fixnum class.

### Public Instance Methods

to_ber() click to toggle source

Converts the fixnum to BER format.

    # File lib/net/ber/core_ext/fixnum.rb, line 6
    def to_ber
      "\0002#{to_ber_internal}"
    end

to_ber_application(tag) click to toggle source

Generate a BER-encoding for an application-defined INTEGER. Examples of such integers are SNMP's Counter, Gauge, and TimeTick types.

    # File lib/net/ber/core_ext/fixnum.rb, line 30
    def to_ber_application(tag)
      [0x40 + tag].pack("C") + to_ber_internal
    end

to_ber_enumerated() click to toggle source

Converts the fixnum to BER enumerated format.

    # File lib/net/ber/core_ext/fixnum.rb, line 12
    def to_ber_enumerated
      "\0012#{to_ber_internal}"
    end

to_ber_length_encoding() click to toggle source

Converts the fixnum to BER length encodining format.

    # File lib/net/ber/core_ext/fixnum.rb, line 18
    def to_ber_length_encoding
      if self <= 127
        [self].pack('C')
      else
        i = [self].pack('N').sub(/^[\00]]+/,"")
        [0x80 + i.length].pack('C') + i
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.