Adds an option to specify the number of copies to print
Cássio Marques
committed Mar 14, 2014
commit bd94ca721ac3800c25cd70b89b0e80b0db60466c
Showing 2
changed files with
17 additions
and 2 deletions
zebra/epl/label.rb b/lib/zebra/epl/label.rb
+6
-1
| @@ | @@ -7,6 +7,7 @@ module Zebra |
| class InvalidPrintDensityError < StandardError; end | |
| class PrintSpeedNotInformedError < StandardError; end | |
| + | attr_writer :copies |
| attr_reader :elements, :tempfile | |
| attr_accessor :width, :length, :gap, :print_speed, :print_density | |
| @@ | @@ -30,6 +31,10 @@ module Zebra |
| @print_density = d | |
| end | |
| + | def copies |
| + | @copies || 1 |
| + | end |
| + | |
| def <<(element) | |
| elements << element | |
| end | |
| @@ | @@ -56,7 +61,7 @@ module Zebra |
| io << element.to_epl << "\n" | |
| end | |
| - | io << "P0\n" |
| + | io << "P#{copies}\n" |
| end | |
| def persist | |
spec/zebra/epl/label_spec.rb
+11
-1
| @@ | @@ -22,6 +22,16 @@ describe Zebra::Epl::Label do |
| label.print_speed.should == 2 | |
| end | |
| + | it "sets the number of copies" do |
| + | label = described_class.new :copies => 4 |
| + | label.copies.should == 4 |
| + | end |
| + | |
| + | it "the number of copies defaults to 1" do |
| + | label = described_class.new |
| + | label.copies.should == 1 |
| + | end |
| + | |
| it "validates the printing speed" do | |
| [-1, 8, "a"].each do |s| | |
| expect { | |
| @@ | @@ -63,7 +73,7 @@ describe Zebra::Epl::Label do |
| label.print_speed = 3 | |
| label.print_density = 10 | |
| label.dump_contents(io) | |
| - | io.should == "O\nQ200,24\nq100\nS3\nD10\n\nN\nfoobar\nblabla\nP0\n" |
| + | io.should == "O\nQ200,24\nq100\nS3\nD10\n\nN\nfoobar\nblabla\nP1\n" |
| end | |
| it "does not try to set the label width when it's not informed (falls back to autosense)" do | |