Class: AfdParser::SetEmployer

Inherits:
RecordParser show all
Defined in:
lib/afd_parser/set_employer.rb

Constant Summary collapse

DOCUMENT_TYPES =
{1 => :cnpj, 2 => :cpf}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ SetEmployer

Returns a new instance of SetEmployer.



29
30
31
32
33
34
35
# File 'lib/afd_parser/set_employer.rb', line 29

def initialize(line)
  self.line_id, self.record_type_id, self.creation_time,
  self.document_type, self.document_number, self.cei, self.name,
  self.location = line.unpack("A9AA12AA14A12A150A100").collect do |str|
    _clean!(str)
  end
end

Instance Attribute Details

#ceiObject

Returns the value of attribute cei.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def cei
  @cei
end

#creation_timeObject

Returns the value of attribute creation_time.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def creation_time
  @creation_time
end

#document_numberObject

Returns the value of attribute document_number.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def document_number
  @document_number
end

#document_typeObject

Returns the value of attribute document_type.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def document_type
  @document_type
end

#line_idObject

Returns the value of attribute line_id.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def line_id
  @line_id
end

#locationObject

Returns the value of attribute location.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def location
  @location
end

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def name
  @name
end

#record_type_idObject

Returns the value of attribute record_type_id.



24
25
26
# File 'lib/afd_parser/set_employer.rb', line 24

def record_type_id
  @record_type_id
end

Class Method Details

.sizeObject



50
51
52
# File 'lib/afd_parser/set_employer.rb', line 50

def self.size
  299
end

Instance Method Details

#==(other) ⇒ Object



54
55
56
57
58
# File 'lib/afd_parser/set_employer.rb', line 54

def ==(other)
  return self.class == other.class && [:line_id, :record_type_id, :creation_time, :document_type, :document_number, :cei, :name, :location].all? do |reader|
    self.send(reader) == other.send(reader)
  end
end

#exportObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/afd_parser/set_employer.rb', line 37

def export
  line_export = ""
  line_export += @line_id.to_s.rjust(9,"0")
  line_export += @record_type_id.to_s
  line_export += format_time(@creation_time)
  line_export += get_document_type_number(@document_type).to_s
  line_export += @document_number.to_s.rjust(14, "0")
  line_export += @cei.to_s.rjust(12, "0")
  line_export += @name.ljust(150, " ")
  line_export += @location.ljust(100, " ")
  line_export
end