Class: Skylark::LDAP::DN

Inherits:
Object
  • Object
show all
Defined in:
lib/skylark/ldap/dn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dn_string) ⇒ DN

Returns a new instance of DN.



6
7
8
# File 'lib/skylark/ldap/dn.rb', line 6

def initialize(dn_string)
	parse!(dn_string)
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



4
5
6
# File 'lib/skylark/ldap/dn.rb', line 4

def names
  @names
end

Instance Method Details

#parse(dn_string) ⇒ Object



14
15
16
17
18
# File 'lib/skylark/ldap/dn.rb', line 14

def parse(dn_string)
	dn_string.scan(/(?<type>OU|CN|DC)=(?<data>[A-z][\w\ -]*),?/i).map do |match|
		{match.first => match.last}
	end
end

#parse!(dn_string) ⇒ Object



10
11
12
# File 'lib/skylark/ldap/dn.rb', line 10

def parse!(dn_string)
	@names = parse(dn_string)
end