Using the correct print command depending on the current platform
Cássio Marques
committed Nov 28, 2013
commit fac8e4bf123b6b533cc1cebc43c6b4313ef6825b
Showing 1
changed file with
9 additions
and 1 deletions
zebra/print_job.rb b/lib/zebra/print_job.rb
+9
-1
| @@ | @@ -18,7 +18,7 @@ module Zebra |
| tempfile = label.persist | |
| begin | |
| - | `lpr -P #{@printer} -o raw #{tempfile.path}` |
| + | send_to_printer tempfile.path |
| ensure | |
| tempfile.close | |
| tempfile.unlink | |
| @@ | @@ -31,5 +31,13 @@ module Zebra |
| existent_printers = Cups.show_destinations | |
| raise UnknownPrinter.new(printer) unless existent_printers.include?(printer) | |
| end | |
| + | |
| + | def send_to_printer(path) |
| + | if RUBY_PLATFORM =~ /darwin/ |
| + | `lpr -P #{@printer} -o raw #{path}` |
| + | else |
| + | `lp -d #{@printer} -o raw #{path}` |
| + | end |
| + | end |
| end | |
| end | |