Class: ActiveLdap::DistinguishedName
- Inherits:
-
Object
- Object
- ActiveLdap::DistinguishedName
- Includes:
- GetTextSupport
- Defined in:
- lib/active_ldap/distinguished_name.rb
Defined Under Namespace
Classes: Parser
Instance Attribute Summary collapse
-
#rdns ⇒ Object
readonly
Returns the value of attribute rdns.
Class Method Summary collapse
Instance Method Summary collapse
- #-(other) ⇒ Object
- #<<(rdn) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(*rdns) ⇒ DistinguishedName
constructor
A new instance of DistinguishedName.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #unshift(rdn) ⇒ Object
Methods included from GetTextSupport
Constructor Details
#initialize(*rdns) ⇒ DistinguishedName
Returns a new instance of DistinguishedName.
158 159 160 161 162 163 |
# File 'lib/active_ldap/distinguished_name.rb', line 158 def initialize(*rdns) @rdns = rdns.collect do |rdn| rdn = {rdn[0] => rdn[1]} if rdn.is_a?(Array) and rdn.size == 2 rdn end end |
Instance Attribute Details
#rdns ⇒ Object (readonly)
Returns the value of attribute rdns.
157 158 159 |
# File 'lib/active_ldap/distinguished_name.rb', line 157 def rdns @rdns end |
Class Method Details
Instance Method Details
#-(other) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/active_ldap/distinguished_name.rb', line 165 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 |
#<<(rdn) ⇒ Object
178 179 180 |
# File 'lib/active_ldap/distinguished_name.rb', line 178 def <<(rdn) @rdns << rdn end |
#<=>(other) ⇒ Object
186 187 188 189 |
# File 'lib/active_ldap/distinguished_name.rb', line 186 def <=>(other) normalize_for_comparing(@rdns) <=> normalize_for_comparing(other.rdns) end |
#==(other) ⇒ Object
191 192 193 194 |
# File 'lib/active_ldap/distinguished_name.rb', line 191 def ==(other) other.is_a?(self.class) and normalize(@rdns) == normalize(other.rdns) end |
#eql?(other) ⇒ Boolean
196 197 198 199 |
# File 'lib/active_ldap/distinguished_name.rb', line 196 def eql?(other) other.is_a?(self.class) and normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s) end |
#hash ⇒ Object
201 202 203 |
# File 'lib/active_ldap/distinguished_name.rb', line 201 def hash normalize(@rdns).to_s.hash end |
#inspect ⇒ Object
205 206 207 |
# File 'lib/active_ldap/distinguished_name.rb', line 205 def inspect super end |
#to_s ⇒ Object
209 210 211 212 213 214 215 216 217 |
# File 'lib/active_ldap/distinguished_name.rb', line 209 def to_s @rdns.collect do |rdn| rdn.sort_by do |type, value| type.upcase end.collect do |type, value| "#{type}=#{escape(value)}" end.join("+") end.join(",") end |
#unshift(rdn) ⇒ Object
182 183 184 |
# File 'lib/active_ldap/distinguished_name.rb', line 182 def unshift(rdn) @rdns.unshift(rdn) end |