Class: Ticketbai::ChecksumCalculator
- Inherits:
-
Object
- Object
- Ticketbai::ChecksumCalculator
- Defined in:
- lib/ticketbai/checksum_calculator.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(data) ⇒ ChecksumCalculator
constructor
A new instance of ChecksumCalculator.
Constructor Details
#initialize(data) ⇒ ChecksumCalculator
Returns a new instance of ChecksumCalculator.
5 6 7 |
# File 'lib/ticketbai/checksum_calculator.rb', line 5 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/ticketbai/checksum_calculator.rb', line 3 def data @data end |
Instance Method Details
#calculate ⇒ Object
9 10 11 12 13 |
# File 'lib/ticketbai/checksum_calculator.rb', line 9 def calculate checksum = Digest::CRC8.checksum(@data) format('%03d', checksum.to_s) end |