Class: PkiExpress::PkiBrazilCertificateFields
- Inherits:
-
Object
- Object
- PkiExpress::PkiBrazilCertificateFields
- Defined in:
- lib/pki_express/pki_brazil_certificate_fields.rb
Instance Attribute Summary collapse
-
#certificate_type ⇒ Object
Returns the value of attribute certificate_type.
-
#cnpj ⇒ Object
Returns the value of attribute cnpj.
-
#company_name ⇒ Object
Returns the value of attribute company_name.
-
#cpf ⇒ Object
Returns the value of attribute cpf.
-
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
-
#oab_numero ⇒ Object
Returns the value of attribute oab_numero.
-
#oab_uf ⇒ Object
Returns the value of attribute oab_uf.
-
#responsavel ⇒ Object
Returns the value of attribute responsavel.
-
#rg_emissor ⇒ Object
Returns the value of attribute rg_emissor.
-
#rg_emissor_uf ⇒ Object
Returns the value of attribute rg_emissor_uf.
-
#rg_numero ⇒ Object
Returns the value of attribute rg_numero.
Instance Method Summary collapse
- #cnpj_formatted ⇒ Object
- #cpf_formatted ⇒ Object
-
#initialize(model) ⇒ PkiBrazilCertificateFields
constructor
A new instance of PkiBrazilCertificateFields.
Constructor Details
#initialize(model) ⇒ PkiBrazilCertificateFields
Returns a new instance of PkiBrazilCertificateFields.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 9 def initialize(model) @certificate_type = nil @cpf = nil @cnpj = nil @responsavel = nil @date_of_birth = nil @company_name = nil @rg_numero = nil @rg_emissor = nil @rg_emissor_uf = nil @oab_numero = nil @oab_uf = nil unless model.nil? @certificate_type = model.fetch(:certificateType) @cpf = model.fetch(:cpf) @cnpj = model.fetch(:cnpj) @responsavel = model.fetch(:responsavel) @date_of_birth = model.fetch(:dateOfBirth) @company_name = model.fetch(:companyName) @rg_numero = model.fetch(:rgNumero) @rg_emissor = model.fetch(:rgEmissor) @rg_emissor_uf = model.fetch(:rgEmissorUF) @oab_numero = model.fetch(:oabNumero) @oab_uf = model.fetch(:oabUF) end end |
Instance Attribute Details
#certificate_type ⇒ Object
Returns the value of attribute certificate_type.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def certificate_type @certificate_type end |
#cnpj ⇒ Object
Returns the value of attribute cnpj.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def cnpj @cnpj end |
#company_name ⇒ Object
Returns the value of attribute company_name.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def company_name @company_name end |
#cpf ⇒ Object
Returns the value of attribute cpf.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def cpf @cpf end |
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def date_of_birth @date_of_birth end |
#oab_numero ⇒ Object
Returns the value of attribute oab_numero.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def oab_numero @oab_numero end |
#oab_uf ⇒ Object
Returns the value of attribute oab_uf.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def oab_uf @oab_uf end |
#responsavel ⇒ Object
Returns the value of attribute responsavel.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def responsavel @responsavel end |
#rg_emissor ⇒ Object
Returns the value of attribute rg_emissor.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def rg_emissor @rg_emissor end |
#rg_emissor_uf ⇒ Object
Returns the value of attribute rg_emissor_uf.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def rg_emissor_uf @rg_emissor_uf end |
#rg_numero ⇒ Object
Returns the value of attribute rg_numero.
5 6 7 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 5 def rg_numero @rg_numero end |
Instance Method Details
#cnpj_formatted ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 47 def cnpj_formatted unless @cnpj return nil end unless /^\d{14}$/.match(@cnpj) return @cnpj end "#{@cnpj[0..1]}.#{@cnpj[2..4]}.#{@cnpj[5..7]}/#{@cnpj[8..11]}-#{@cnpj[12..-1]}" end |
#cpf_formatted ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/pki_express/pki_brazil_certificate_fields.rb', line 37 def cpf_formatted unless @cpf return nil end unless /^\d{11}$/.match(@cpf) return @cpf end "#{@cpf[0..2]}.#{@cpf[3..5]}.#{@cpf[6..8]}-#{@cpf[9..-1]}" end |