Class: EdiParser::DocumentHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/edi_parser/document_header.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ DocumentHeader

Returns a new instance of DocumentHeader.



7
8
9
# File 'lib/edi_parser/document_header.rb', line 7

def initialize(id)
  self.document_id = id
end

Instance Attribute Details

#document_idString

Returns the document header identifier.

Returns:

  • (String)

    the document header identifier.



5
6
7
# File 'lib/edi_parser/document_header.rb', line 5

def document_id
  @document_id
end

Class Method Details

.parse(line) ⇒ Object



11
12
13
14
# File 'lib/edi_parser/document_header.rb', line 11

def self.parse(line)
  raise InvalidDocumentHeaderError, "Line #{line} doesn't begin with 340 header (OCORRENCIA DA NOTA FISCAL)" unless line.start_with?("340")
  DocumentHeader.new(line[3..26].strip)
end