class EdiParser::CarrierData

Attributes

cnpj[RW]

@return [String] the carrier cnpj.

corporate_name[RW]

@return [String] the carrier corporate name.

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/edi_parser/carrier_data.rb, line 10
def initialize(attributes = {})
  attributes.each do |key, value|
    __send__("#{key}=", value)
  end
end
parse(line) click to toggle source
# File lib/edi_parser/carrier_data.rb, line 16
def self.parse(line)
  raise InvalidCarrierDataError, "Line #{line} doesn't begin with 000 header (DADOS DA TRANSPORTADORA)" unless line.start_with?("341")
  CarrierData.new(cnpj: line[3..16].strip, corporate_name: line[17..56].strip)
end