class Zebra::PrintJob

Attributes

printer[R]

Public Class Methods

new(printer) click to toggle source
# File lib/zebra/print_job.rb, line 6
def initialize(printer)
  @printer = printer
end

Public Instance Methods

print(label, ip, print_service: "") click to toggle source

Private Instance Methods

send_to_printer(path, print_service) click to toggle source
# File lib/zebra/print_job.rb, line 24
def send_to_printer(path, print_service)
  puts "* * * * * * * * * * * * Sending file to printer #{@printer} at #{@remote_ip} * * * * * * * * * * "
  case print_service
  when "rlpr"
    system("rlpr -H #{@remote_ip} -P #{@printer} -o #{path} 2>&1") # try printing to LPD on windows machine
  when "lp"
    system("lp -h #{@remote_ip} -d #{@printer} -o raw #{path}") # print to unix (CUPS) using lp
  else 
    result = system("rlpr -H #{@remote_ip} -P #{@printer} -o #{path} 2>&1") # try printing to LPD on windows machine first
    system("lp -h #{@remote_ip} -d #{@printer} -o raw #{path}") if !result # print to unix (CUPS) if rlpr failed
  end
end