未定义的方法`two_dimensional?'使用 Barby CairoOutputter
undefined method `two_dimensional?' using Barby CairoOutputter
我只想使用 rqrcode gem 生成二维码。当我创建新的 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>)
你知道我可以做些什么来纠正这个错误吗?
宝石文件:
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
如 the project 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
实现需要这些方法。
我只想使用 rqrcode gem 生成二维码。当我创建新的 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>)
你知道我可以做些什么来纠正这个错误吗?
宝石文件:
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
如 the project 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
实现需要这些方法。