class RqrcodeRenderer::SizeCalculator
Constants
- QR_CHAR_SIZE_VS_SIZE
size - seems to follow this logic
# | input | modules | size | created
Public Class Methods
minimum_qr_size_from_string(string)
click to toggle source
# File lib/rqrcode_renderer/size_calculator.rb, line 27 def minimum_qr_size_from_string(string) QR_CHAR_SIZE_VS_SIZE.each_with_index do |size, index| return (index + 1) if string.size < size end # If it's particularly big, we'll try and create codes until it accepts i = QR_CHAR_SIZE_VS_SIZE.size begin i += 1 RQRCode::QRCode.new(string, size: i) i rescue RQRCode::QRCodeRunTimeError retry end end