Sha256: 7f4af268d579a752aec089a64d3be76b902c84abd0b481ddab194afe45463459
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require "zebra/zpl/printable" module Zebra module Zpl class Qrcode include Printable class InvalidScaleFactorError < StandardError; end class InvalidCorrectionLevelError < StandardError; end attr_reader :scale_factor, :correction_level def width=(width) @width = width || 0 end def scale_factor=(value) raise InvalidScaleFactorError unless (1..99).include?(value.to_i) @scale_factor = value end def correction_level=(value) raise InvalidCorrectionLevelError unless %w[L M Q H].include?(value.to_s) @correction_level = value end def to_zpl check_attributes "^FW#{rotation}^FO#{x},#{y}^BQN,2,#{scale_factor},,3^FD#{correction_level}A,#{data}^FS" end private def check_attributes super raise MissingAttributeError.new("the scale factor to be used is not given") unless @scale_factor raise MissingAttributeError.new("the error correction level to be used is not given") unless @correction_level end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zebra-zpl-1.0.5 | lib/zebra/zpl/qrcode.rb |