Class: LDAP::Filter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ldap/filter/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
13
14
15
# File 'lib/ldap/filter/base.rb', line 6

def initialize key, value, options={}
  options = {
    inverse: false
  }.merge! options

  @key = key
  @value = value.to_s
  @wildcard_placements = [options[:wildcard]].flatten
  @not = options[:inverse]
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/ldap/filter/base.rb', line 4

def key
  @key
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/ldap/filter/base.rb', line 4

def value
  @value
end

Instance Method Details

#!Object



24
25
26
27
# File 'lib/ldap/filter/base.rb', line 24

def !
  @not = !@not
  self
end

#&(filter) ⇒ Object



37
38
39
# File 'lib/ldap/filter/base.rb', line 37

def & filter
  AndFilter.new [self, filter]
end

#<<(value) ⇒ Object



29
30
31
# File 'lib/ldap/filter/base.rb', line 29

def << value
  OrFilter.new @key, @value, value
end

#to_sObject



17
18
19
20
21
22
# File 'lib/ldap/filter/base.rb', line 17

def to_s
  filter = '('
  filter << '!' if @not
  filter << condition
  filter << ')'
end

#|(filter) ⇒ Object



33
34
35
# File 'lib/ldap/filter/base.rb', line 33

def | filter
  OrFilter.new [self, filter]
end