Class: CFDI::Certificado
- Inherits:
-
OpenSSL::X509::Certificate
- Object
- OpenSSL::X509::Certificate
- CFDI::Certificado
- Defined in:
- lib/certificado.rb
Overview
Certificados en formato X590
En español, el archivo ‘.cer`
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
el certificado en Base64.
-
#noCertificado ⇒ Object
readonly
el número de certificado.
Instance Method Summary collapse
-
#certifica(factura) ⇒ CFDI::Comprobante
Certifica una factura.
-
#initialize(file) ⇒ CFDI::Certificado
constructor
Importar un certificado de sellado.
Constructor Details
#initialize(file) ⇒ CFDI::Certificado
Importar un certificado de sellado
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/certificado.rb', line 19 def initialize (file) if file.is_a? String file = File.read(file) end super file @noCertificado = ''; # Normalmente son strings de tipo: # 3230303031303030303030323030303030323933 # por eso sólo tomamos cada segundo dígito self.serial.to_s(16).scan(/.{2}/).each {|v| @noCertificado += v[1]; } @data = self.to_s.gsub(/^-.+/, '').gsub(/\n/, '') end |
Instance Attribute Details
#data ⇒ Object (readonly)
el certificado en Base64
13 14 15 |
# File 'lib/certificado.rb', line 13 def data @data end |
#noCertificado ⇒ Object (readonly)
el número de certificado
11 12 13 |
# File 'lib/certificado.rb', line 11 def noCertificado @noCertificado end |
Instance Method Details
#certifica(factura) ⇒ CFDI::Comprobante
Certifica una factura
41 42 43 44 45 46 |
# File 'lib/certificado.rb', line 41 def certifica factura factura.noCertificado = @noCertificado factura.certificado = @data end |