-
Notifications
You must be signed in to change notification settings - Fork 171
Open
Description
I keep on getting the following warning message:
/home/alexander/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/barby-0.6.8/lib/barby/outputter/rmagick_outputter.rb:56: warning: passing a block without an image argument is deprecated
The code that this error arises from:
#Returns an instance of Magick::Image
def to_image(opts={})
with_options opts do
b = background #Capture locally because Magick::Image.new block uses instance_eval
canvas = Magick::Image.new(full_width, full_height){ self.background_color = b }
...My code:
require 'barby'
require 'barby/barcode/code_128'
require 'barby/outputter/ascii_outputter'
require 'barby/outputter/html_outputter'
require 'barby/outputter/rmagick_outputter'
class BarcodeGenerator
def self.generate_barcode_for_lumber_unit(lumber_unit)
barcode = Barby::Code128B.new(lumber_unit.uuid)
outputter = Barby::RmagickOutputter.new(barcode)
filename = "barcode_#{DateTime.now.strftime('%Y%m%d%H%M%S%L')}.png"
filepath = "app/assets/images/#{filename}"
f = File.open(filepath, 'wb')
f.write(outputter.to_png(height: 50))
f.close
lumber_unit.barcode.attach(io: File.open(filepath), filename:)
lumber_unit.save!
end
endThe line that raises this error:
f.write(outputter.to_png(height: 50))Can anyone suggest how I might amend my code to stop raising the deprecation warning? I scrutinised the documentation here but I couldn't work it out.
plainlystated
Metadata
Metadata
Assignees
Labels
No labels