Class: Teodoro::ArquivoXML

Inherits:
Object
  • Object
show all
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
  S2190
  S2200
  S2205
  S2206
  S2210
  S2220
  S2230
  S2240
  S2250
  S2299
  S2300
  S2306
  S2399
  S3000
].freeze
TIPOS_DE_EVENTO_RETIFICAVEIS =
%w[
  S2190
  S2200
  S2205
  S2206
  S2210
  S2220
  S2230
  S2240
  S2250
  S2299
  S2300
  S2306
  S2399
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#momento_de_processamento_pelo_e_socialObject (readonly)

Returns the value of attribute momento_de_processamento_pelo_e_social.



85
86
87
# File 'lib/teodoro/arquivo_xml.rb', line 85

def momento_de_processamento_pelo_e_social
  @momento_de_processamento_pelo_e_social
end

#numero_do_recibo_a_retificarObject (readonly)

Returns the value of attribute numero_do_recibo_a_retificar.



85
86
87
# File 'lib/teodoro/arquivo_xml.rb', line 85

def numero_do_recibo_a_retificar
  @numero_do_recibo_a_retificar
end

Instance Method Details

#carregarObject

otimizacao do gerenciamento de memoria



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/teodoro/arquivo_xml.rb', line 88

def carregar
  Console.print "carregando #{nome}.xml..." do
    evento, recibo = carregar_evento_e_recibo

    @retificacao = evento_retificavel? && evento['ideEvento/indRetif'] == '2'
    @numero_do_recibo_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

#nomeObject



110
111
112
# File 'lib/teodoro/arquivo_xml.rb', line 110

def nome
  @nome ||= File.basename(caminho, '.xml')
end

#processarObject



114
115
116
117
118
119
120
121
# File 'lib/teodoro/arquivo_xml.rb', line 114

def processar
  Console.print "processando #{nome}.xml..." do
    validar_versao_do_leiaute
    processar_arquivo
  end
rescue StandardError => e
  tratar_excecao(e)
end

#processavel?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/teodoro/arquivo_xml.rb', line 106

def processavel?
  TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento)
end

#retificacao?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/teodoro/arquivo_xml.rb', line 102

def retificacao?
  @retificacao
end