class EdiParser::Ocurrence
Attributes
code[RW]
@return [String] the ocurrence code.
date[RW]
@return [DateTime] the ocurrence date and time.
geoposition[RW]
@return [String] the ocurrence textual geoposition.
incoming_code[RW]
@return [String] the ocurrence incoming code.
invoice[RW]
@return [EdiParser::Invoice] the invoice object.
sender_cnpj[RW]
@return [String] the sender’s cnpj.
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/edi_parser/ocurrence.rb, line 22 def initialize(attributes = {}) attributes.each do |key, value| __send__("#{key}=", value) end end
parse(line)
click to toggle source
# File lib/edi_parser/ocurrence.rb, line 28 def self.parse(line) return nil unless line.start_with?("342") ocurrence = Ocurrence.new ocurrence.sender_cnpj = line[3..16] ocurrence.invoice = Invoice.new(number: line[20..27].to_i, series: line[17..19].strip) ocurrence.code = line[28..29] ocurrence.date = DateTime.strptime(line[30, 41], "%d%m%Y%H%M") ocurrence.incoming_code = line[42..43].strip ocurrence.geoposition = line[44..113].strip ocurrence end