Sha256: 7407946396666249a181b4b341bea7b916deb8acad6ae93fe11df7bd298d9d11
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'stringio' module Net::BER::Extensions::String ## # 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. def to_ber(code = 0x04) [code].pack('C') + length.to_ber_length_encoding + self end ## # Creates an application-specific BER string encoded value with the # provided syntax code value. def to_ber_application_string(code) to_ber(0x40 + code) end ## # Creates a context-specific BER string encoded value with the provided # syntax code value. def to_ber_contextspecific(code) to_ber(0x80 + code) end ## # Nondestructively reads a BER object from this string. def read_ber(syntax = nil) StringIO.new(self).read_ber(syntax) end ## # Destructively reads a BER object from the string. def read_ber!(syntax = nil) io = StringIO.new(self) result = io.read_ber(syntax) self.slice!(0...io.pos) return result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scashin133-net-ldap-0.1.4 | lib/net/ber/core_ext/string.rb |
scashin133-net-ldap-0.1.3 | lib/net/ber/core_ext/string.rb |
scashin133-net-ldap-0.1.2 | lib/net/ber/core_ext/string.rb |