Class: Teodoro::ArquivoXML
- Inherits:
-
Object
- Object
- Teodoro::ArquivoXML
- Defined in:
- lib/teodoro/arquivo_xml.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- TIPOS_DE_EVENTO_PROCESSAVEIS =
%w[ S1000 S1005 S1010 S1020 S1030 S1040 S1050 S1070 S1298 S1299 S2190 S2200 S2205 S2206 S2210 S2220 S2230 S2240 S2250 S2298 S2299 S2300 S2306 S2399 S2500 S2501 S3000 S3500 ].freeze
- TIPOS_DE_EVENTO_RETIFICAVEIS =
%w[ S2190 S2200 S2205 S2206 S2210 S2220 S2230 S2240 S2250 S2299 S2300 S2306 S2399 S2500 S2501 ].freeze
- VERSOES_DE_LEIAUTE_2 =
%w[ 02_04_01 02_04_02 02_05_00 ].freeze
- VERSOES_DE_LEIAUTE_SIMPLIFICADO =
%w[ _S_01_00_00 _S_01_01_00 _S_01_02_00 ].freeze
Instance Attribute Summary collapse
-
#arquivo_retificado ⇒ Object
Returns the value of attribute arquivo_retificado.
-
#indice ⇒ Object
Returns the value of attribute indice.
-
#momento_de_processamento_pelo_e_social ⇒ Object
readonly
Returns the value of attribute momento_de_processamento_pelo_e_social.
-
#recibo_do_evento_a_excluir ⇒ Object
readonly
Returns the value of attribute recibo_do_evento_a_excluir.
-
#recibo_do_evento_a_retificar ⇒ Object
readonly
Returns the value of attribute recibo_do_evento_a_retificar.
Instance Method Summary collapse
-
#carregar ⇒ Object
otimizacao do gerenciamento de memoria.
- #exclusao_por_recibo? ⇒ Boolean
- #nome ⇒ Object
- #processar ⇒ Object
- #processavel? ⇒ Boolean
- #retificacao? ⇒ Boolean
- #s1000? ⇒ Boolean
Instance Attribute Details
#arquivo_retificado ⇒ Object
Returns the value of attribute arquivo_retificado.
112 113 114 |
# File 'lib/teodoro/arquivo_xml.rb', line 112 def arquivo_retificado @arquivo_retificado end |
#indice ⇒ Object
Returns the value of attribute indice.
112 113 114 |
# File 'lib/teodoro/arquivo_xml.rb', line 112 def indice @indice end |
#momento_de_processamento_pelo_e_social ⇒ Object (readonly)
Returns the value of attribute momento_de_processamento_pelo_e_social.
114 115 116 |
# File 'lib/teodoro/arquivo_xml.rb', line 114 def @momento_de_processamento_pelo_e_social end |
#recibo_do_evento_a_excluir ⇒ Object (readonly)
Returns the value of attribute recibo_do_evento_a_excluir.
114 115 116 |
# File 'lib/teodoro/arquivo_xml.rb', line 114 def recibo_do_evento_a_excluir @recibo_do_evento_a_excluir end |
#recibo_do_evento_a_retificar ⇒ Object (readonly)
Returns the value of attribute recibo_do_evento_a_retificar.
114 115 116 |
# File 'lib/teodoro/arquivo_xml.rb', line 114 def recibo_do_evento_a_retificar @recibo_do_evento_a_retificar end |
Instance Method Details
#carregar ⇒ Object
otimizacao do gerenciamento de memoria
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/teodoro/arquivo_xml.rb', line 117 def carregar Console.print "carregando #{nome}.xml (#{percentual}%)..." do evento, recibo = carregar_evento_e_recibo @recibo_do_evento_a_excluir = evento['infoExclusao/nrRecEvt'] if exclusao_por_recibo? @retificacao = evento_retificavel? && evento['ideEvento/indRetif'] == '2' @recibo_do_evento_a_retificar = evento['ideEvento/nrRecibo'] if retificacao? @momento_de_processamento_pelo_e_social = recibo['processamento/dhProcessamento'] validar_carregamento end rescue StandardError => e tratar_excecao(e) end |
#exclusao_por_recibo? ⇒ Boolean
136 137 138 |
# File 'lib/teodoro/arquivo_xml.rb', line 136 def exclusao_por_recibo? tipo_de_evento == 'S3000' end |
#nome ⇒ Object
132 133 134 |
# File 'lib/teodoro/arquivo_xml.rb', line 132 def nome @nome ||= File.basename(caminho, '.xml') end |
#processar ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/teodoro/arquivo_xml.rb', line 152 def processar Console.print "processando #{nome}.xml (#{percentual}%)..." do validar_versao_do_leiaute processar_arquivo end rescue StandardError => e tratar_excecao(e) end |
#processavel? ⇒ Boolean
144 145 146 |
# File 'lib/teodoro/arquivo_xml.rb', line 144 def processavel? TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento) end |
#retificacao? ⇒ Boolean
140 141 142 |
# File 'lib/teodoro/arquivo_xml.rb', line 140 def retificacao? @retificacao end |
#s1000? ⇒ Boolean
148 149 150 |
# File 'lib/teodoro/arquivo_xml.rb', line 148 def s1000? tipo_de_evento == 'S1000' end |