Module: Caligrafo::Reader::LineExtension

Defined in:
lib/caligrafo/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arquivoObject

Returns the value of attribute arquivo.



35
36
37
# File 'lib/caligrafo/reader.rb', line 35

def arquivo
  @arquivo
end

#numeroObject

Returns the value of attribute numero.



35
36
37
# File 'lib/caligrafo/reader.rb', line 35

def numero
  @numero
end

#numero_retornoObject

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

Raises:

  • (ArgumentError)


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_secaoObject



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_camposObject



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

#secaoObject



37
38
39
# File 'lib/caligrafo/reader.rb', line 37

def secao
  @secao.nome
end

#secao?(nome_secao) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/caligrafo/reader.rb', line 41

def secao?(nome_secao)
  @arquivo.secoes.find {|s| s.nome == nome_secao }
end