# encoding: utf-8 module Zebra module Zpl class Label class InvalidPrintSpeedError < StandardError; end class InvalidPrintDensityError < StandardError; end class PrintSpeedNotInformedError < StandardError; end attr_writer :copies attr_reader :elements, :tempfile attr_accessor :width, :length, :gap, :print_speed, :print_density def initialize(options = {}) options.each_pair { |key, value| self.__send__("#{key}=", value) if self.respond_to?("#{key}=") } @elements = [] end def length_and_gap=(length_and_gap) self.length = length_and_gap[0] self.gap = length_and_gap[1] end def print_speed=(s) raise InvalidPrintSpeedError unless (0..6).include?(s) @print_speed = s end def print_density=(d) raise InvalidPrintDensityError unless (0..6).include?(d) @print_density = d end def copies @copies || 1 end def <<(element) element.width = self.width elements << element end def dump_contents(io = STDOUT) check_required_configurations # Start format io << "^XA" # ^LL