Module: Net::BER::Extensions::String

### Home Classes Methods

### In Files

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

### Methods

- #read_ber
- #read_ber!
- #to_ber
- #to_ber_application_string
- #to_ber_contextspecific

### 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::String

BER extensions to the String class.

### Public Instance Methods

read_ber(syntax = nil) click to toggle source

Nondestructively reads a BER object from this string.

    # File lib/net/ber/core_ext/string.rb, line 45
    def read_ber(syntax = nil)
      StringIO.new(self).read_ber(syntax)
    end

read_ber!(syntax = nil) click to toggle source

Destructively reads a BER object from the string.

    # File lib/net/ber/core_ext/string.rb, line 51
    def read_ber!(syntax = nil)
      io = StringIO.new(self)

      result = io.read_ber(syntax)
      self.slice!(0...io.pos)

      return result
    end

to_ber(code = 0x04) click to toggle source

Converts a string to a BER string. Universal octet-strings are tagged with 0x04, but other values are possible depending on the context, so we let the caller give us one.

User code should call either to_ber_application_string or to_ber_contextspecific.

    # File lib/net/ber/core_ext/string.rb, line 13
    def to_ber(code = 0x04)
      raw_string = raw_utf8_encoded
      [code].pack('C') + raw_string.length.to_ber_length_encoding + raw_string
    end

to_ber_application_string(code) click to toggle source

Creates an application-specific BER string encoded value with the provided syntax code value.

    # File lib/net/ber/core_ext/string.rb, line 32
    def to_ber_application_string(code)
      to_ber(0x40 + code)
    end

to_ber_contextspecific(code) click to toggle source

Creates a context-specific BER string encoded value with the provided syntax code value.

    # File lib/net/ber/core_ext/string.rb, line 39
    def to_ber_contextspecific(code)
      to_ber(0x80 + code)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.