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
  S2230
  S2250
  S2299
  S2300
  S2306
  S2399
  S3000
].freeze
TIPOS_DE_EVENTO_RETIFICAVEIS =
%w[
  S2200
  S2205
  S2206
  S2230
  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.



56
57
58
# File 'lib/teodoro/arquivo_xml.rb', line 56

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.



56
57
58
# File 'lib/teodoro/arquivo_xml.rb', line 56

def numero_do_recibo_a_retificar
  @numero_do_recibo_a_retificar
end

Instance Method Details

#carregarObject

otimizacao do gerenciamento de memoria



59
60
61
62
63
64
65
66
67
# File 'lib/teodoro/arquivo_xml.rb', line 59

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

    @retificacao = TIPOS_DE_EVENTO_RETIFICAVEIS.include?(tipo_de_evento) && evento['ideEvento/indRetif'] == '2'
    @numero_do_recibo_a_retificar = evento['ideEvento/nrRecibo'] if retificacao?
    @momento_de_processamento_pelo_e_social = recibo['processamento/dhProcessamento']
  end
end

#nomeObject



77
78
79
# File 'lib/teodoro/arquivo_xml.rb', line 77

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

#processarObject



81
82
83
84
85
86
# File 'lib/teodoro/arquivo_xml.rb', line 81

def processar
  Console.print "processando #{nome}.xml..." do
    validar_versao_do_leiaute
    processar_arquivo
  end
end

#processavel?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/teodoro/arquivo_xml.rb', line 73

def processavel?
  TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento)
end

#retificacao?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/teodoro/arquivo_xml.rb', line 69

def retificacao?
  @retificacao
end