From b4c28477f9592d48d30df12dc956e5195136e951 Mon Sep 17 00:00:00 2001 From: blackhedd Date: Wed, 26 Apr 2006 02:10:34 +0000 Subject: [PATCH] documentation --- lib/net/ldap/filter.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/net/ldap/filter.rb b/lib/net/ldap/filter.rb index 96be82d..e16a42e 100644 --- a/lib/net/ldap/filter.rb +++ b/lib/net/ldap/filter.rb @@ -83,14 +83,36 @@ class Filter def Filter::ge attribute, value; Filter.new :ge, attribute, value; end def Filter::le attribute, value; Filter.new :le, attribute, value; end + # #pres( attribute ) is a synonym for #eq( attribute, "*" ) + # + def Filter::pres attribute; Filter.eq attribute, "*"; end + + # operator & ("AND") is used to conjoin two or more filters. + # This expression will select only entries that have an objectclass + # attribute AND have a mail attribute that begins with "George": + # f = Net::LDAP::Filter.pres( "objectclass" ) & Net::LDAP::Filter.eq( "mail", "George*" ) + # def & filter; Filter.new :and, self, filter; end + + # operator | ("OR") is used to disjoin two or more filters. + # This expression will select entries that have either an objectclass + # attribute OR a mail attribute that begins with "George": + # f = Net::LDAP::Filter.pres( "objectclass" ) | Net::LDAP::Filter.eq( "mail", "George*" ) + # def | filter; Filter.new :or, self, filter; end + + # + # operator ~ ("NOT") is used to negate a filter. + # This expression will select only entries that do not have an objectclass + # attribute: + # f = ~ Net::LDAP::Filter.pres( "objectclass" ) # #-- # This operator can't be !, evidently. Try it. def ~@; Filter.new :not, self, nil; end + def to_s case @op when :ne