Class: Sped2DB::Registro
- Inherits:
-
Object
- Object
- Sped2DB::Registro
- Defined in:
- lib/sped2db/registro.rb
Instance Attribute Summary collapse
-
#campos ⇒ Object
readonly
Returns the value of attribute campos.
-
#nome ⇒ Object
readonly
Returns the value of attribute nome.
-
#pai ⇒ Object
readonly
Returns the value of attribute pai.
-
#valores ⇒ Object
readonly
Returns the value of attribute valores.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(linha, metadados) ⇒ Registro
constructor
A new instance of Registro.
- #to_h ⇒ Object
Constructor Details
#initialize(linha, metadados) ⇒ Registro
Returns a new instance of Registro.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sped2db/registro.rb', line 5 def initialize(linha, ) @linha = linha = @valores = dividir_linha_em_valores linha @nome = @valores.shift.upcase validar_registro @pai = [@nome]['pai'] @campos = [@nome]['campos'] validar_campos corrigir_caracteres_especiais corrigir_datas @hash = to_h end |
Instance Attribute Details
#campos ⇒ Object (readonly)
Returns the value of attribute campos.
3 4 5 |
# File 'lib/sped2db/registro.rb', line 3 def campos @campos end |
#nome ⇒ Object (readonly)
Returns the value of attribute nome.
3 4 5 |
# File 'lib/sped2db/registro.rb', line 3 def nome @nome end |
#pai ⇒ Object (readonly)
Returns the value of attribute pai.
3 4 5 |
# File 'lib/sped2db/registro.rb', line 3 def pai @pai end |
#valores ⇒ Object (readonly)
Returns the value of attribute valores.
3 4 5 |
# File 'lib/sped2db/registro.rb', line 3 def valores @valores end |
Instance Method Details
#[](key) ⇒ Object
29 30 31 |
# File 'lib/sped2db/registro.rb', line 29 def [](key) @hash[key.to_sym] end |
#to_h ⇒ Object
24 25 26 27 |
# File 'lib/sped2db/registro.rb', line 24 def to_h valores = @valores.map { |v| v.empty? ? nil : v } @campos.map(&:to_sym).zip(valores).to_h end |