Sha256: 0fcc9c3a0cc3b557945880b29f352f2a3c736fb974c68a670b442c07b60dc350

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 Bytes

Contents

module Zebra
  class PrintJob
    # class UnknownPrinter < StandardError
    #   def initialize(printer)
    #     super("Could not find a printer named #{printer}")
    #   end
    # end

    attr_reader :printer

    def initialize(printer)
      #check_existent_printers printer

      @printer = printer
    end

    def print(label, ip)
      @remote_ip = ip
      tempfile = label.persist
      send_to_printer tempfile.path
    end

    private

    # def check_existent_printers(printer)
    #   existent_printers = Cups.show_destinations
    #   raise UnknownPrinter.new(printer) unless existent_printers.include?(printer)
    # end

    def send_to_printer(path)
      puts "* * * * * * * * * * * * Sending file to printer #{@printer} at #{@remote_ip} * * * * * * * * * * "
      `lp -h #{@remote_ip} -d #{@printer} -o raw #{path}`
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zebra-zpl-1.0.2 lib/zebra/print_job.rb
zebra-zpl-1.0.0 lib/zebra/print_job.rb