lib/zebra/epl/label.rb in zebra-epl-0.0.6 vs lib/zebra/epl/label.rb in zebra-epl-0.0.7

- old
+ new

@@ -5,10 +5,11 @@ 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}=") } @@ -28,10 +29,14 @@ def print_density=(d) raise InvalidPrintDensityError unless (0..15).include?(d) @print_density = d end + def copies + @copies || 1 + end + def <<(element) elements << element end def dump_contents(io = STDOUT) @@ -54,10 +59,10 @@ elements.each do |element| io << element.to_epl << "\n" end - io << "P0\n" + io << "P#{copies}\n" end def persist tempfile = Tempfile.new "zebra_label" dump_contents tempfile