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.



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

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

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



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

def records
  @records
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.parse(ldif) ⇒ Object



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

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

Instance Method Details

#<<(record) ⇒ Object



613
614
615
# File 'lib/active_ldap/ldif.rb', line 613

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

#==(other) ⇒ Object



629
630
631
632
# File 'lib/active_ldap/ldif.rb', line 629

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

#each(&block) ⇒ Object



617
618
619
# File 'lib/active_ldap/ldif.rb', line 617

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

#to_sObject



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

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