Sha256: e5cabfcb595061bd33d42381104fc480c543c55557ef6acda56677567a4aaec2
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
module QRCoder module SizeCalculator # size - seems to follow this logic # # | input | modules # | size | created #-------|-------|-------- # 1 | 7 | 21 # 2 | 14 | 25 (+4) # 3 | 24 | 29 - # 4 | 34 | 33 - # 5 | 44 | 37 - # 6 | 58 | 41 - # 7 | 64 | 45 - # 8 | 84 | 49 - # 9 | 98 | 53 - # 10 | 119 | 57 - # 11 | 137 | 61 - # 12 | 155 | 65 - # 13 | 177 | 69 - # 14 | 194 | 73 - QR_CHAR_SIZE_VS_SIZE = [7, 14, 24, 34, 44, 58, 64, 84, 98, 119, 137, 155, 177, 194] 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 QRCoder::QRCode.new(string, :size => i) return i rescue QRCoder::QRCodeRunTimeError retry end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
qrcoder-0.1.3 | lib/qrcoder/size_calculator.rb |
qrcoder-0.1.2 | lib/rqrcoder/size_calculator.rb |
qrcoder-0.1.1 | lib/rqrcoder/size_calculator.rb |
qrcoder-0.1 | lib/rqrcoder/size_calculator.rb |