Class: AfdParser::Trailer
- Inherits:
-
RecordParser
- Object
- RecordParser
- AfdParser::Trailer
- Defined in:
- lib/afd_parser/trailer.rb
Instance Attribute Summary collapse
-
#clock_in_out ⇒ Object
readonly
Returns the value of attribute clock_in_out.
-
#line_id ⇒ Object
readonly
Returns the value of attribute line_id.
-
#record_type_id ⇒ Object
readonly
Returns the value of attribute record_type_id.
-
#set_employee ⇒ Object
readonly
Returns the value of attribute set_employee.
-
#set_employer ⇒ Object
readonly
Returns the value of attribute set_employer.
-
#set_time ⇒ Object
readonly
Returns the value of attribute set_time.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #export ⇒ Object
-
#initialize(*args) ⇒ Trailer
constructor
A new instance of Trailer.
Methods inherited from RecordParser
Constructor Details
#initialize(*args) ⇒ Trailer
Returns a new instance of Trailer.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/afd_parser/trailer.rb', line 26 def initialize(*args) if args.size == 1 counter = args[0] @line_id = 999999999 @set_employer = counter[:set_employer] @clock_in_out = counter[:clock_in_out] @set_time = counter[:set_time] @set_employee = counter[:set_employee] @record_type_id = 9 elsif args.size == 2 line = args[0] counter = args[1] line_id, set_employer, clock_in_out, set_time, set_employee, record_type_id = line.unpack("A9A9A9A9A9A").collect{|str| _clean!(str)} @line_id = line_id.to_i @set_employer = set_employer.to_i @clock_in_out = clock_in_out.to_i @set_time = set_time.to_i @set_employee = set_employee.to_i @record_type_id = record_type_id.to_i ["set_employer", "clock_in_out", "set_time", "set_employee"].each do |key| value = eval("@"+key) if value != counter[key.to_sym] raise AfdParser::AfdParserException.new("Mismatch counting changes of #{key} in REP!\n" + "REP: #{value.to_s} | System: #{counter[key.to_sym].to_s}") end end else raise AfdParser::AfdParserException.new("wrong number of arguments for trailer object, should be 1 or 2") end end |
Instance Attribute Details
#clock_in_out ⇒ Object (readonly)
Returns the value of attribute clock_in_out.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def clock_in_out @clock_in_out end |
#line_id ⇒ Object (readonly)
Returns the value of attribute line_id.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def line_id @line_id end |
#record_type_id ⇒ Object (readonly)
Returns the value of attribute record_type_id.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def record_type_id @record_type_id end |
#set_employee ⇒ Object (readonly)
Returns the value of attribute set_employee.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def set_employee @set_employee end |
#set_employer ⇒ Object (readonly)
Returns the value of attribute set_employer.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def set_employer @set_employer end |
#set_time ⇒ Object (readonly)
Returns the value of attribute set_time.
24 25 26 |
# File 'lib/afd_parser/trailer.rb', line 24 def set_time @set_time end |
Class Method Details
.time ⇒ Object
74 75 76 |
# File 'lib/afd_parser/trailer.rb', line 74 def self.time 46 end |
Instance Method Details
#==(other) ⇒ Object
78 79 80 81 82 |
# File 'lib/afd_parser/trailer.rb', line 78 def ==(other) return self.class == other.class && [:line_id, :set_employer, :clock_in_out, :set_time, :set_employee, :record_type_id].all? do |reader| self.send(reader) == other.send(reader) end end |
#export ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/afd_parser/trailer.rb', line 63 def export line_export = "" line_export += @line_id.to_s.rjust(9,"0") line_export += @set_employer.to_s.rjust(9,"0") line_export += @clock_in_out.to_s.rjust(9,"0") line_export += @set_time.to_s.rjust(9,"0") line_export += @set_employee.to_s.rjust(9,"0") line_export += @record_type_id.to_s line_export end |