Class: Ticketbai::TbaiQr
- Inherits:
-
Object
- Object
- Ticketbai::TbaiQr
- Defined in:
- lib/ticketbai/tbai_qr.rb
Constant Summary collapse
- BASE_URL =
'https://batuz.eus/QRTBAI/?'.freeze
- ID_TBAI_NAME =
param names
'id'.freeze
- SERIAL_NAME =
's'.freeze
- NUMBER_NAME =
'nf'.freeze
- TOTAL_NAME =
'i'.freeze
- CRC_NAME =
'cr'.freeze
Instance Attribute Summary collapse
-
#id_tbai ⇒ Object
Returns the value of attribute id_tbai.
-
#number ⇒ Object
Returns the value of attribute number.
-
#serial ⇒ Object
Returns the value of attribute serial.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
-
#create ⇒ String
Builds the Ticketbai QR URL.
-
#initialize(**args) ⇒ TbaiQr
constructor
A new instance of TbaiQr.
Constructor Details
#initialize(**args) ⇒ TbaiQr
Returns a new instance of TbaiQr.
20 21 22 23 24 25 |
# File 'lib/ticketbai/tbai_qr.rb', line 20 def initialize(**args) self.id_tbai = args[:id_tbai] self.serial = args[:serial] self.number = args[:number] self.total = args[:total] end |
Instance Attribute Details
#id_tbai ⇒ Object
Returns the value of attribute id_tbai.
12 13 14 |
# File 'lib/ticketbai/tbai_qr.rb', line 12 def id_tbai @id_tbai end |
#number ⇒ Object
Returns the value of attribute number.
12 13 14 |
# File 'lib/ticketbai/tbai_qr.rb', line 12 def number @number end |
#serial ⇒ Object
Returns the value of attribute serial.
12 13 14 |
# File 'lib/ticketbai/tbai_qr.rb', line 12 def serial @serial end |
#total ⇒ Object
Returns the value of attribute total.
12 13 14 |
# File 'lib/ticketbai/tbai_qr.rb', line 12 def total @total end |
Instance Method Details
#create ⇒ String
Builds the Ticketbai QR URL. Example: batuz.eus/QRTBAI/?id=TBAI-00000006Y-251019-btFpwP8dcLGAF-237&s=T&nf=27174&i=4.70&cr=007
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ticketbai/tbai_qr.rb', line 31 def create encoded_params = [ format_param(ID_TBAI_NAME, @id_tbai), format_param(SERIAL_NAME, @serial), format_param(NUMBER_NAME, @number), format_param(TOTAL_NAME, @total) ].join('&') crc = ChecksumCalculator.new(BASE_URL + encoded_params).calculate BASE_URL + [encoded_params, format_param(CRC_NAME, crc)].join('&') end |