Sha256: 5c836b0ac315b8d78ee212e2ab3c07d286be2912906f4e51e83d14a7157e0694
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'tempfile' module MultiEncoder class BarcodeImage < AbstractImage DEFAULT_ENCODING = Gbarcode::BARCODE_128 | Gbarcode::BARCODE_NO_CHECKSUM def type 'barcodes' end def write barcode = Gbarcode.barcode_create @contents.upcase Gbarcode.barcode_encode extract_options(barcode), DEFAULT_ENCODING FileUtils.mkdir_p directory eps = File.open("#{eps_path}", 'wb') begin Gbarcode.barcode_print barcode, eps, Gbarcode::BARCODE_OUT_EPS eps.close system("convert #{eps_path} #{file_path}") ensure FileUtils.rm(eps) if File.exists? eps_path end save if respond_to? :save end private def extract_options(bc) bc.width = @options[:width] if @options[:width] bc.height = @options[:height] if @options[:height] bc.scalef = @options[:scaling_factor] if @options[:scaling_factor] bc.xoff = @options[:xoff] if @options[:xoff] bc.yoff = @options[:yoff] if @options[:yoff] bc.margin = @options[:margin] if @options[:margin] bc end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
barcode_encoder-0.0.9 | lib/multi_encoder/images/barcode.rb |
multi_encoder-0.0.9 | lib/multi_encoder/images/barcode.rb |
multi_encoder-0.0.8 | lib/multi_encoder/images/barcode.rb |