Class: ActiveLdap::DistinguishedName::Parser
- Inherits:
-
Object
- Object
- ActiveLdap::DistinguishedName::Parser
- Defined in:
- lib/active_ldap/distinguished_name.rb
Instance Attribute Summary collapse
-
#dn ⇒ Object
readonly
Returns the value of attribute dn.
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 |
# File 'lib/active_ldap/distinguished_name.rb', line 7 def initialize(source) @dn = nil @source = source end |
Instance Attribute Details
#dn ⇒ Object (readonly)
Returns the value of attribute dn.
6 7 8 |
# File 'lib/active_ldap/distinguished_name.rb', line 6 def dn @dn end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_ldap/distinguished_name.rb', line 12 def parse return @dn if @dn rdns = [] scanner = StringScanner.new(@source) scanner.scan(/\s*/) raise rdn_is_missing if scanner.scan(/\s*\+\s*/) raise name_component_is_missing if scanner.scan(/\s*,\s*/) rdn = {} until scanner.eos? type = scan_attribute_type(scanner) skip_attribute_type_and_value_separator(scanner) value = scan_attribute_value(scanner) rdn[type] = value if scanner.scan(/\s*\+\s*/) raise rdn_is_missing if scanner.eos? elsif scanner.scan(/\s*\,\s*/) rdns << rdn rdn = {} raise name_component_is_missing if scanner.eos? else scanner.scan(/\s*/) rdns << rdn if scanner.eos? end end @dn = DN.new(*rdns) @dn end |