Class: Zebra::PrintJob

Inherits:
Object
  • Object
show all
Defined in:
lib/zebra/print_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(printer) ⇒ PrintJob

Returns a new instance of PrintJob.



6
7
8
# File 'lib/zebra/print_job.rb', line 6

def initialize(printer)
  @printer = printer
end

Instance Attribute Details

#printerObject (readonly)

Returns the value of attribute printer.



4
5
6
# File 'lib/zebra/print_job.rb', line 4

def printer
  @printer
end

Instance Method Details



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/zebra/print_job.rb', line 10

def print(label, ip, print_service: "")
  @remote_ip = ip
  if label.is_a? String
    tempfile = Tempfile.new "zebra_label"
    tempfile.write label
    tempfile.close
  else
    tempfile = label.persist
  end
  send_to_printer(tempfile.path, print_service)
end