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.



574
575
576
577
# File 'lib/active_ldap/ldif.rb', line 574

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

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



573
574
575
# File 'lib/active_ldap/ldif.rb', line 573

def records
  @records
end

#versionObject (readonly)

Returns the value of attribute version.



573
574
575
# File 'lib/active_ldap/ldif.rb', line 573

def version
  @version
end

Class Method Details

.parse(ldif) ⇒ Object



566
567
568
# File 'lib/active_ldap/ldif.rb', line 566

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

Instance Method Details

#<<(record) ⇒ Object



579
580
581
# File 'lib/active_ldap/ldif.rb', line 579

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

#==(other) ⇒ Object



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

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

#each(&block) ⇒ Object



583
584
585
# File 'lib/active_ldap/ldif.rb', line 583

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

#to_sObject



587
588
589
590
591
592
593
# File 'lib/active_ldap/ldif.rb', line 587

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