Sha256: 1021f14577b588bd4e126849c79cca56791cbe2d6b2a6d91b56efd57c9e31c7a
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 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 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 ["b#{x}", y, "Q", "s#{scale_factor}", "e#{correction_level}", "\"#{data}\""].join(",") 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zebra-zpl-1.0.2 | lib/zebra/zpl/qrcode.rb |
zebra-zpl-1.0.1 | lib/zebra/zpl/qrcode.rb |
zebra-zpl-1.0.0 | lib/zebra/zpl/qrcode.rb |