我只想使用rqrcode gem生成一个QR代码。当我创建新的rqrcode实例时:
qr = RQRCode::QRCode.new('test')我得到以下输入:
xxxxxxx x x x xxxxxx x xxxxxxx
x x xx xxxxx xx x x
x xxx x x x xxxx xx x xxx x
x xxx x x x x x x x xx x xxx x
x xxx x x xxx xxx x x xxx x
x x xxx x xx x x
xxxxxxx x x x x x x x x x xxxxxxx
x x xx x x
xxxx xxxxx xxxx x xx x
x xx xxxx xxxx xxxx x xxx
xx x xx x x xxxx xx
x x x xxx xxxxxxx x xx xxx x
x xxxxxxx x x x xxxx xx xx xx
x x x xx xxx x x xxxx
xx xxx xxx xxx x xxxxx xxx
xx x xx xxx xx x x
x xxxx xx xxxx x x x x x
x xxx x x x xx x xx xx x
xxx xx xx x x xx xx
x x x x xx xx xx x
x xxxx xx xx x x x xxxx xx
x x x xxx x xx xxx xxx
x xx x xxx x x x xx
xx x xxx xxxx x x x x x
xx x xxxx xx x x xxxxxxxxx
x xx xx x x xx xx x
xxxxxxx xx x xxxxx x xxx
x x xx xx x xxxx xx x xx
x xxx x xx x xxx xxxxx xxx
x xxx x xx x xxxxxxxx xxx
x xxx x x xx xx x
x x xxxxxxxxx x xx xx xx
xxxxxxx x xx x xx x x x xx x为了打印我的qr_code,我使用了Barby的CairoOutputter,但是当我试图将输出转换为svg,png,.我收到以下错误消息:
NoMethodError (undefined method `two_dimensional?' for #<RQRCode::QRCode:0x0000000794bd88>)你对我能做些什么来纠正这个错误有什么想法吗?
Gemfile:
gem 'rqrcode','~> 0.4.2'
gem 'barby'
gem 'cairo'在我的模型中:
require 'barby'
require 'barby/outputter/cairo_outputter'
require 'rqrcode'
qr = RQRCode::QRCode.new('test')
puts qr
outputter = Barby::CairoOutputter.new(qr).to_svg发布于 2017-06-07 10:27:32
正如README中所述,您需要使用一个受支持的barcode类。也就是说,您需要使用Barby::QrCode,而不是RQRCode::QRCode。
安装了以下库:
gem install 'barby' # core library
gem install 'cairo' # dependency for output
gem install 'rqrcode' # dependency for barcode以下实现工作正常:
require 'barby'
require 'barby/outputter/cairo_outputter'
require 'barby/barcode/qr_code'
qr = Barby::QrCode.new('test')
outputter = Barby::CairoOutputter.new(qr).to_svg与RQRCode::QRCode不同,Barby::QrCode实现了two_dimensional?和encoding等方法--这是Barby::CairoOutputter实现所必需的。
https://stackoverflow.com/questions/44408548
复制相似问题