Sha256: 291efe9b003b614ad074a2cb9980d6f478d0e84fc3090e3070745497e601b4e7

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 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)
      Cups::PrintJob.new(label.path, @printer).print
    end

    private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zebra-epl-0.0.1 lib/zebra/print_job.rb