# File lib/active_ldap/distinguished_name.rb, line 161 def escape_value(value) if /(\A | \z)/.match(value) '"' + value.gsub(/([\\\"])/, '\\\1') + '"' else value.gsub(/([,=\+<>#;\\\"])/, '\\\1') end end
# File lib/active_ldap/distinguished_name.rb, line 185 def +(other) self.class.new(*(@rdns + other.rdns)) end
# File lib/active_ldap/distinguished_name.rb, line 189 def -(other) rdns = @rdns.dup normalized_rdns = normalize(@rdns) normalize(other.rdns).reverse_each do |rdn| if rdn == normalized_rdns.pop rdns.pop else raise ArgumentError, _("%s isn't sub DN of %s") % [other, self] end end self.class.new(*rdns) end
# File lib/active_ldap/distinguished_name.rb, line 202 def <<(rdn) @rdns << rdn self end
# File lib/active_ldap/distinguished_name.rb, line 216 def <=>(other) other = DN.parse(other) if other.is_a?(String) return nil unless other.is_a?(self.class) normalize_for_comparing(@rdns) <=> normalize_for_comparing(other.rdns) end
# File lib/active_ldap/distinguished_name.rb, line 223 def ==(other) case other when self.class normalize(@rdns) == normalize(other.rdns) when String parsed_other = nil begin parsed_other = self.class.parse(other) rescue DistinguishedNameInvalid return false end self == parsed_other else false end end
# File lib/active_ldap/distinguished_name.rb, line 181 def blank? @rdns.blank? end
# File lib/active_ldap/distinguished_name.rb, line 240 def eql?(other) other.is_a?(self.class) and normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s) end
# File lib/active_ldap/distinguished_name.rb, line 245 def hash normalize(@rdns).to_s.hash end
# File lib/active_ldap/distinguished_name.rb, line 211 def parent return nil if @rdns.size <= 1 self.class.new(*@rdns[1..-1]) end
# File lib/active_ldap/distinguished_name.rb, line 264 def to_human_readable_format to_s.inspect end
# File lib/active_ldap/distinguished_name.rb, line 249 def to_s klass = self.class @rdns.collect do |rdn| rdn.sort_by do |type, value| type.upcase end.collect do |type, value| "#{type}=#{klass.escape_value(value)}" end.join("+") end.join(",") end
Generated with the Darkfish Rdoc Generator 2.