Module: Caligrafo::Reader::LineExtension
- Defined in:
- lib/caligrafo/reader.rb
Instance Attribute Summary collapse
-
#arquivo ⇒ Object
Returns the value of attribute arquivo.
-
#numero ⇒ Object
Returns the value of attribute numero.
-
#numero_retorno ⇒ Object
Returns the value of attribute numero_retorno.
Instance Method Summary collapse
- #campo(nome_campo) ⇒ Object
- #descobrir_secao ⇒ Object
- #ler(nome_campo) ⇒ Object
- #ler_campos ⇒ Object
- #preencher(nome_campo, novo_valor) ⇒ Object
- #secao ⇒ Object
- #secao?(nome_secao) ⇒ Boolean
Instance Attribute Details
#arquivo ⇒ Object
Returns the value of attribute arquivo.
35 36 37 |
# File 'lib/caligrafo/reader.rb', line 35 def arquivo @arquivo end |
#numero ⇒ Object
Returns the value of attribute numero.
35 36 37 |
# File 'lib/caligrafo/reader.rb', line 35 def numero @numero end |
#numero_retorno ⇒ Object
Returns the value of attribute numero_retorno.
35 36 37 |
# File 'lib/caligrafo/reader.rb', line 35 def numero_retorno @numero_retorno end |
Instance Method Details
#campo(nome_campo) ⇒ Object
65 66 67 68 69 |
# File 'lib/caligrafo/reader.rb', line 65 def campo(nome_campo) campo = @secao.campos.find {|c| c.nome == nome_campo } raise ArgumentError, "campo com o nome '#{nome_campo}' nao foi encontrado." unless campo campo end |
#descobrir_secao ⇒ Object
61 62 63 |
# File 'lib/caligrafo/reader.rb', line 61 def descobrir_secao @secao = @arquivo.secoes.find {|s| s.dessa_linha?(self) } end |
#ler(nome_campo) ⇒ Object
45 46 47 |
# File 'lib/caligrafo/reader.rb', line 45 def ler(nome_campo) self.campo(nome_campo).ler(self) end |
#ler_campos ⇒ Object
55 56 57 58 59 |
# File 'lib/caligrafo/reader.rb', line 55 def ler_campos hash = {} @secao.campos.each {|c| hash[c.nome] = c.ler(self) } hash end |
#preencher(nome_campo, novo_valor) ⇒ Object
49 50 51 52 53 |
# File 'lib/caligrafo/reader.rb', line 49 def preencher(nome_campo, novo_valor) campo = self.campo(nome_campo) self[campo.intervalo] = campo.formatar(novo_valor) self end |
#secao ⇒ Object
37 38 39 |
# File 'lib/caligrafo/reader.rb', line 37 def secao @secao.nome end |
#secao?(nome_secao) ⇒ Boolean
41 42 43 |
# File 'lib/caligrafo/reader.rb', line 41 def secao?(nome_secao) @arquivo.secoes.find {|s| s.nome == nome_secao } end |