58 lines
1.2 KiB
Ruby
Executable File
58 lines
1.2 KiB
Ruby
Executable File
require 'net/http'
|
|
require 'cups'
|
|
|
|
class Printer::PrinterWorker
|
|
attr_accessor :print_settings
|
|
|
|
def initialize(print_settings)
|
|
self.print_settings = print_settings
|
|
end
|
|
|
|
def printer_destination()
|
|
if self.print_settings
|
|
self.print_settings.printer_name
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
def print_copies()
|
|
if self.print_settings
|
|
self.print_settings.print_copies.to_i
|
|
else
|
|
return 1
|
|
end
|
|
end
|
|
|
|
# Options from printer name
|
|
def self.printer_options(printer_name)
|
|
Cups.options_for(printer_name)
|
|
end
|
|
|
|
def self.printers()
|
|
Cups.show_destinations
|
|
end
|
|
|
|
def self.default_printer()
|
|
Cups.default_printer
|
|
end
|
|
|
|
def print(file_path,printer_destination = nil )
|
|
# if printer_destination.nil?
|
|
# printer_destination = self.printer_destination
|
|
# end
|
|
|
|
# puts printer_destination
|
|
# puts '........Printer Destination..........'
|
|
|
|
# copy = self.print_copies
|
|
# #Print only when printer information is not null
|
|
# if !self.printer_destination.nil?
|
|
# (1..copy).each do
|
|
# page = Cups::PrintJob.new(file_path, printer_destination)
|
|
# page.print
|
|
# end
|
|
# end
|
|
end
|
|
end
|