Class: Net::LDAP::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ldap/entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(dn = nil) ⇒ Entry

Returns a new instance of Entry.



38
39
40
41
# File 'lib/net/ldap/entry.rb', line 38

def initialize dn = nil
  @myhash = Hash.new {|k,v| k[v] = [] }
  @myhash[:dn] = [dn]
end

Instance Method Details

#[](name) ⇒ Object

– We have to deal with this one as we do []= because this one and not the other one gets called in formulations like entry << cn.



55
56
57
58
# File 'lib/net/ldap/entry.rb', line 55

def [] name
  name = name.to_s.downcase.intern unless name.is_a?(Symbol)
  @myhash[name]
end

#[]=(name, value) ⇒ Object



44
45
46
47
# File 'lib/net/ldap/entry.rb', line 44

def []= name, value
  sym = name.to_s.downcase.intern
  @myhash[sym] = value
end

#attribute_namesObject



64
65
66
# File 'lib/net/ldap/entry.rb', line 64

def attribute_names
  @myhash.keys
end

#dnObject



60
61
62
# File 'lib/net/ldap/entry.rb', line 60

def dn
  self[:dn][0]
end

#eachObject Also known as: each_attribute



68
69
70
71
72
# File 'lib/net/ldap/entry.rb', line 68

def each
  if block_given?
    attribute_names.each {|a| yield a, self[a] }
  end
end