Class: Nfse::Envio::Tomador

Inherits:
Mustache
  • Object
show all
Defined in:
lib/nfse/tomador.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Tomador

Returns a new instance of Tomador.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nfse/tomador.rb', line 12

def initialize(args)
    self.template_path = File.expand_path("../../templates/", __FILE__)
    
    @cpf_cnpj = args[:cpf_cnpj]                
    @razao_social = args[:razao_social]
    @endereco = args[:endereco]
    @endereco_numero = args[:endereco_numero]
    @complemento = args[:complemento]
    @bairro = args[:bairro]
    @cod_cidade = args[:cod_cidade]
    @uf = args[:uf]
    @cep = args[:cep]
    @telefone = args[:telefone]
    @email = args[:email]

    self.formatted_doc()
end

Instance Attribute Details

#bairroObject

Returns the value of attribute bairro.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def bairro
  @bairro
end

#cepObject

Returns the value of attribute cep.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def cep
  @cep
end

#cnpjObject

Returns the value of attribute cnpj.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def cnpj
  @cnpj
end

#cod_cidadeObject

Returns the value of attribute cod_cidade.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def cod_cidade
  @cod_cidade
end

#complementoObject

Returns the value of attribute complemento.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def complemento
  @complemento
end

#cpfObject

Returns the value of attribute cpf.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def cpf
  @cpf
end

#cpf_cnpjObject

Returns the value of attribute cpf_cnpj.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def cpf_cnpj
  @cpf_cnpj
end

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def email
  @email
end

#enderecoObject

Returns the value of attribute endereco.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def endereco
  @endereco
end

#endereco_numeroObject

Returns the value of attribute endereco_numero.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def endereco_numero
  @endereco_numero
end

#razao_socialObject

Returns the value of attribute razao_social.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def razao_social
  @razao_social
end

#telefoneObject

Returns the value of attribute telefone.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def telefone
  @telefone
end

#ufObject

Returns the value of attribute uf.



7
8
9
# File 'lib/nfse/tomador.rb', line 7

def uf
  @uf
end

Instance Method Details

#formatted_docObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/nfse/tomador.rb', line 30

def formatted_doc
    doc = @cpf_cnpj
    doc = doc.tr('.', '').tr('-', '').tr('/', '')
    
    if doc.length == 14
        @cnpj = doc
    else 
        @cpf = doc
    end
end

#has_address?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/nfse/tomador.rb', line 41

def has_address?
    [@endereco, @endereco_numero, @bairro, @cod_cidade, @uf, @cep].all?
end

#has_contact?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/nfse/tomador.rb', line 45

def has_contact?
    [@telefone, @email].any?
end