LDAPSyntax

class
Superclass
Object
Included Modules
Treequel::Constants::Patterns
Extended With
Loggability
Treequel::AttributeDeclarations

This is a class for representing ldapSyntax declarations in a Treequel::Schema.

Attributes

desc[RW]

The syntax's description

extensions[RW]

The syntax's extensions (as a String)

oid[R]

The syntax's oid

schema[R]

The schema the syntax belongs to

Public Class Methods

anchor
new( schema, oid, desc=nil, extensions=nil )

Create a new LDAPSyntax

# File lib/treequel/schema/ldapsyntax.rb, line 47
def initialize( schema, oid, desc=nil, extensions=nil )

        @schema     = schema

        @oid        = oid
        @desc       = desc
        @extensions = extensions

        super()
end
anchor
parse( schema, description )

Parse an LDAPSyntax entry from an ldapSyntax description from a schema.

# File lib/treequel/schema/ldapsyntax.rb, line 27
def self::parse( schema, description )
        unless match = ( LDAP_SYNTAX_DESCRIPTION.match(description) )
                raise Treequel::ParseError, "failed to parse syntax from %p" % [ description ]
        end

        oid, desc, extensions = match.captures
        # Treequel.logger.debug "  parsed syntax: %p" % [ match.captures ]

        # Normalize the attributes
        desc  = Treequel::Schema.unquote_desc( desc )

        return self.new( schema, oid, desc, extensions )
end

Public Instance Methods

anchor
inspect()

Return a human-readable representation of the object suitable for debugging

# File lib/treequel/schema/ldapsyntax.rb, line 92
def inspect
        return "#<%s:0x%0x %s(%s)>" % [
                self.class.name,
                self.object_id / 2,
                self.oid,
                self.desc,
        ]
end
anchor
to_s()

Returns the SyntaxDescription as a String, which is the RFC4512-style schema description.

# File lib/treequel/schema/ldapsyntax.rb, line 82
def to_s
        parts = [ self.oid ]
        parts << "DESC '%s'" % [ self.desc ] if self.desc
        parts << self.extensions.strip unless self.extensions.empty?

        return "( %s )" % [ parts.join(' ') ]
end