Class: Cfdi40::XmlLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/cfdi40/xml_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_string, mode) ⇒ XmlLoader

Returns a new instance of XmlLoader.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cfdi40/xml_loader.rb', line 9

def initialize(xml_string, mode)
  @xml_doc = Nokogiri::XML(xml_string)
  @mode = mode
  # TODO. validar versión del CFDI definido en xml_doc
  @cfdi = Cfdi40::Comprobante.new
  @cfdi.load_from_ng_node(xml_doc.root)
  @cfdi.load_cert
  load_emisor
  load_receptor
  load_conceptos
  load_impuestos
  load_pagos
  load_tfd

  @cfdi.lock if readonly?
  @cfdi.loaded_xml = xml_string
  @cfdi
end

Instance Attribute Details

#cfdiObject (readonly)

Returns the value of attribute cfdi.



7
8
9
# File 'lib/cfdi40/xml_loader.rb', line 7

def cfdi
  @cfdi
end

#modeObject (readonly)

Returns the value of attribute mode.



7
8
9
# File 'lib/cfdi40/xml_loader.rb', line 7

def mode
  @mode
end

#xml_docObject (readonly)

Returns the value of attribute xml_doc.



7
8
9
# File 'lib/cfdi40/xml_loader.rb', line 7

def xml_doc
  @xml_doc
end