Parent

Methods

Included Modules

Files

Class/Module Index [+]

Quicksearch

ActiveLdap::DistinguishedName::Parser

Attributes

dn[R]

Public Class Methods

new(source) click to toggle source
# File lib/active_ldap/distinguished_name.rb, line 11
def initialize(source)
  @dn = nil
  source = source.to_s if source.is_a?(DN)
  unless source.is_a?(String)
    raise DistinguishedNameInputInvalid.new(source)
  end
  @source = source
end

Public Instance Methods

parse() click to toggle source
# File lib/active_ldap/distinguished_name.rb, line 20
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.