When I used rqr_code with reference to the existing article, the undefined method `dark?'Was displayed.
rqr_code installation
$ gem install rqrcode_png
Full copy of basic code
require 'rqrcode'
require 'rqrcode_png'
require 'chunky_png'
qr = RQRCode::QRCode.new( "Hello World!!", size: 3, level: :h)
img = qr.to_img
img.resize(200, 200).save("hello_world.png ")
Execution error
$ ruby qr_code.rb
Traceback (most recent call last):
<Omission>
rqrcode_png/sequence.rb:11:in `block (2 levels) in dark_squares_only': undefined method `dark?' for #<RQRCode::QRCode:0x00007f9126021200> (NoMethodError)
I was able to avoid it with .as_png instead of .to_img.
ruby:.to_img.as_Change to png
require 'rqrcode'
require 'rqrcode_png'
require 'chunky_png'
qr = RQRCode::QRCode.new( "Hello World!!", size: 3, level: :h)
# img = qr.to_img
img = qr.as_png
img.resize(200, 200).save("hello_world.png ")
[Ruby] QR code generation and embedding https://qiita.com/koteko/items/d6d033997c544c47b718
How to easily generate a QR code image in Ruby https://qiita.com/sakaitaka/items/c753103c93fa177e4466
rqrcode https://github.com/whomwah/rqrcode
Recommended Posts