Class: AfdParser::SetEmployee

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

Constant Summary collapse

OPERATION_TYPE =
{"I" => :add, "A" => :edit, "E" => :remove}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ SetEmployee

Returns a new instance of SetEmployee.



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

def initialize(line)
  self.line_id, self.record_type_id, self.creation_time,
  self.operation_type =
    line.unpack("A9AA12A").collect{|str| _clean!(str)}
  self.pis, self.name = line[23..-1].match(/\A(\d{1,12})(.{1,52})/)[1..2].collect{|str| _clean!(str)}
end

Instance Attribute Details

#creation_timeObject

Returns the value of attribute creation_time.



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

def creation_time
  @creation_time
end

#line_idObject

Returns the value of attribute line_id.



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

def line_id
  @line_id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#operation_typeObject

Returns the value of attribute operation_type.



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

def operation_type
  @operation_type
end

#pisObject

Returns the value of attribute pis.



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

def pis
  @pis
end

#record_type_idObject

Returns the value of attribute record_type_id.



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

def record_type_id
  @record_type_id
end

Class Method Details

.sizeObject



47
48
49
# File 'lib/afd_parser/set_employee.rb', line 47

def self.size
  87
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
54
55
# File 'lib/afd_parser/set_employee.rb', line 51

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

#exportObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/afd_parser/set_employee.rb', line 36

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_operation_letter(@operation_type).to_s
  line_export += @pis.to_s.rjust(12,"0")
  line_export += @name.ljust(52, " ")
  line_export
end