Class: Ticketbai::TbaiIdentifier
- Inherits:
-
Object
- Object
- Ticketbai::TbaiIdentifier
- Defined in:
- lib/ticketbai/tbai_identifier.rb
Constant Summary collapse
- ID =
'TBAI'.freeze
Instance Attribute Summary collapse
-
#invoice_date ⇒ Object
Returns the value of attribute invoice_date.
-
#nif ⇒ Object
Returns the value of attribute nif.
-
#signature_value ⇒ Object
Returns the value of attribute signature_value.
Instance Method Summary collapse
-
#create ⇒ String
Builds the TBAI Identifier with the following format: TBAI-NIF-FechaExpedicionFactura(DDMMAA)-SignatureValue(13)-CRC(3).
-
#initialize(**args) ⇒ TbaiIdentifier
constructor
A new instance of TbaiIdentifier.
Constructor Details
#initialize(**args) ⇒ TbaiIdentifier
Returns a new instance of TbaiIdentifier.
12 13 14 15 16 |
# File 'lib/ticketbai/tbai_identifier.rb', line 12 def initialize(**args) self.nif = args[:nif] self.invoice_date = args[:invoice_date] self.signature_value = args[:signature_value][0..12] end |
Instance Attribute Details
#invoice_date ⇒ Object
Returns the value of attribute invoice_date.
5 6 7 |
# File 'lib/ticketbai/tbai_identifier.rb', line 5 def invoice_date @invoice_date end |
#nif ⇒ Object
Returns the value of attribute nif.
5 6 7 |
# File 'lib/ticketbai/tbai_identifier.rb', line 5 def nif @nif end |
#signature_value ⇒ Object
Returns the value of attribute signature_value.
5 6 7 |
# File 'lib/ticketbai/tbai_identifier.rb', line 5 def signature_value @signature_value end |
Instance Method Details
#create ⇒ String
Builds the TBAI Identifier with the following format: TBAI-NIF-FechaExpedicionFactura(DDMMAA)-SignatureValue(13)-CRC(3)
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ticketbai/tbai_identifier.rb', line 22 def create identifier = [ID, @nif, @invoice_date, @signature_value].join('-') identifier << '-' crc = ChecksumCalculator.new(identifier).calculate identifier << crc identifier end |