Skip to content

Commit b4c2847

Browse files
author
blackhedd
committed
documentation
1 parent e231a53 commit b4c2847

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/net/ldap/filter.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,36 @@ def Filter::lt attribute, value; Filter.new :lt, attribute, value; end
8383
def Filter::ge attribute, value; Filter.new :ge, attribute, value; end
8484
def Filter::le attribute, value; Filter.new :le, attribute, value; end
8585

86+
# #pres( attribute ) is a synonym for #eq( attribute, "*" )
87+
#
88+
def Filter::pres attribute; Filter.eq attribute, "*"; end
89+
90+
# operator & ("AND") is used to conjoin two or more filters.
91+
# This expression will select only entries that have an <tt>objectclass</tt>
92+
# attribute AND have a <tt>mail</tt> attribute that begins with "George":
93+
# f = Net::LDAP::Filter.pres( "objectclass" ) & Net::LDAP::Filter.eq( "mail", "George*" )
94+
#
8695
def & filter; Filter.new :and, self, filter; end
96+
97+
# operator | ("OR") is used to disjoin two or more filters.
98+
# This expression will select entries that have either an <tt>objectclass</tt>
99+
# attribute OR a <tt>mail</tt> attribute that begins with "George":
100+
# f = Net::LDAP::Filter.pres( "objectclass" ) | Net::LDAP::Filter.eq( "mail", "George*" )
101+
#
87102
def | filter; Filter.new :or, self, filter; end
88103

104+
105+
#
106+
# operator ~ ("NOT") is used to negate a filter.
107+
# This expression will select only entries that <i>do not</i> have an <tt>objectclass</tt>
108+
# attribute:
109+
# f = ~ Net::LDAP::Filter.pres( "objectclass" )
89110
#
90111
#--
91112
# This operator can't be !, evidently. Try it.
92113
def ~@; Filter.new :not, self, nil; end
93114

115+
94116
def to_s
95117
case @op
96118
when :ne

0 commit comments

Comments
 (0)