Ruby创建QR码

require 'rubygems'
require 'rqrcode'
require 'qr_image'

# QR Code parameters
text = 'This is a test'
size = 4
level = 'h'
 
# Produce the QR Code
qr = RQRCode::QRCode.new(text,  :size => size, :level => level)
 
# Create the image and double its size
img = QRImage.new(qr).sample(6)
 
# Write image to disk
img.write('./qr.png') { quality = 100 }

编程技巧