Class: ActiveLdap::Ldif

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_ldap/ldif.rb

Defined Under Namespace

Modules: Attribute, Attributes Classes: AddRecord, ChangeRecord, ContentRecord, DeleteRecord, ModifyDNRecord, ModifyNameRecord, ModifyRDNRecord, ModifyRecord, Parser, Record, Scanner

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records = []) ⇒ Ldif

Returns a new instance of Ldif.



602
603
604
605
# File 'lib/active_ldap/ldif.rb', line 602

def initialize(records=[])
  @version = 1
  @records = records
end

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



601
602
603
# File 'lib/active_ldap/ldif.rb', line 601

def records
  @records
end

#versionObject (readonly)

Returns the value of attribute version.



601
602
603
# File 'lib/active_ldap/ldif.rb', line 601

def version
  @version
end

Class Method Details

.parse(ldif) ⇒ Object



594
595
596
# File 'lib/active_ldap/ldif.rb', line 594

def parse(ldif)
  Parser.new(ldif).parse
end

Instance Method Details

#<<(record) ⇒ Object



607
608
609
# File 'lib/active_ldap/ldif.rb', line 607

def <<(record)
  @records << record
end

#==(other) ⇒ Object



623
624
625
626
# File 'lib/active_ldap/ldif.rb', line 623

def ==(other)
  other.is_a?(self.class) and
    @version == other.version and @records == other.records
end

#each(&block) ⇒ Object



611
612
613
# File 'lib/active_ldap/ldif.rb', line 611

def each(&block)
  @records.each(&block)
end

#to_sObject



615
616
617
618
619
620
621
# File 'lib/active_ldap/ldif.rb', line 615

def to_s
  result = "version: #{@version}\n"
  result << @records.collect do |record|
    record.to_s
  end.join("\n")
  result
end