Skip to content

Commit 50541f6

Browse files
author
blackhedd
committed
supported filter types greaterorequal and lessorequal
1 parent f3e05db commit 50541f6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/net/ldap/filter.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ def initialize op, a, b
7575
# This example selects any entry with a <tt>mail</tt> value containing
7676
# the substring "anderson":
7777
# f = Net::LDAP::Filter.eq( "mail", "*anderson*" )
78+
#--
79+
# Removed gt and lt. They ain't in the standard!
7880
#
7981
def Filter::eq attribute, value; Filter.new :eq, attribute, value; end
8082
def Filter::ne attribute, value; Filter.new :ne, attribute, value; end
81-
def Filter::gt attribute, value; Filter.new :gt, attribute, value; end
82-
def Filter::lt attribute, value; Filter.new :lt, attribute, value; end
83+
#def Filter::gt attribute, value; Filter.new :gt, attribute, value; end
84+
#def Filter::lt attribute, value; Filter.new :lt, attribute, value; end
8385
def Filter::ge attribute, value; Filter.new :ge, attribute, value; end
8486
def Filter::le attribute, value; Filter.new :le, attribute, value; end
8587

@@ -110,6 +112,7 @@ def | filter; Filter.new :or, self, filter; end
110112
#
111113
#--
112114
# This operator can't be !, evidently. Try it.
115+
# Removed GT and LT. They're not in the RFC.
113116
def ~@; Filter.new :not, self, nil; end
114117

115118

@@ -119,10 +122,10 @@ def to_s
119122
"(!(#{@left}=#{@right}))"
120123
when :eq
121124
"(#{@left}=#{@right})"
122-
when :gt
123-
"#{@left}>#{@right}"
124-
when :lt
125-
"#{@left}<#{@right}"
125+
#when :gt
126+
# "#{@left}>#{@right}"
127+
#when :lt
128+
# "#{@left}<#{@right}"
126129
when :ge
127130
"#{@left}>=#{@right}"
128131
when :le
@@ -202,6 +205,10 @@ def to_ber
202205
else #equality
203206
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 3
204207
end
208+
when :ge
209+
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 5
210+
when :le
211+
[@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 6
205212
when :and
206213
ary = [@left.coalesce(:and), @right.coalesce(:and)].flatten
207214
ary.map {|a| a.to_ber}.to_ber_contextspecific( 0 )

0 commit comments

Comments
 (0)