Class: ActiveLdap::DistinguishedName::Parser
- Inherits:
-
Object
- Object
- ActiveLdap::DistinguishedName::Parser
- Includes:
- GetTextSupport
- 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
Methods included from GetTextSupport
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
11 12 13 14 |
# File 'lib/active_ldap/distinguished_name.rb', line 11 def initialize(source) @dn = nil @source = source end |
Instance Attribute Details
#dn ⇒ Object (readonly)
Returns the value of attribute dn.
10 11 12 |
# File 'lib/active_ldap/distinguished_name.rb', line 10 def dn @dn end |
Instance Method Details
#parse ⇒ Object
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 43 44 45 46 |
# File 'lib/active_ldap/distinguished_name.rb', line 16 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 |