Class: Driver::Base::Print

Inherits:
Extface::Driver
  • Object
show all
Defined in:
app/models/extface/driver/base/print.rb

Constant Summary collapse

NAME =
'Print Device Name'.freeze
GROUP =
Extface::PRINT_DRIVER
DEVELOPMENT =

driver is not ready for production (not passing all tests or has major bugs)

true
RAW =

Select driver features

true
true
FISCAL =

POS, slip printers

false
REPORT =

cash registers, fiscal printers

false
CHAR_COLUMNS =

only transmit data that must be parsed by handler, CDR, report devices

30

Instance Method Summary collapse

Instance Method Details

#char_columnsObject



104
105
106
# File 'app/models/extface/driver/base/print.rb', line 104

def char_columns
  self.class::CHAR_COLUMNS
end

#check_statusObject



58
59
60
# File 'app/models/extface/driver/base/print.rb', line 58

def check_status
  return true #just pass
end

alias_method :print, :push



19
20
21
22
23
24
25
# File 'app/models/extface/driver/base/print.rb', line 19

def print(text)
  if device.encoding.present?
    push text.encode(device.encoding)
  else
    push text
  end
end


84
85
86
# File 'app/models/extface/driver/base/print.rb', line 84

def print_center_row(text, padstr = ' ')
  print "#{text.truncate(char_columns).center(char_columns, padstr)}\r\n"
end


62
63
64
# File 'app/models/extface/driver/base/print.rb', line 62

def print_edges_row(text1, text2)
  print "#{text1} #{text2.rjust(char_columns - text1.length - 1)}\r\n"
end


72
73
74
# File 'app/models/extface/driver/base/print.rb', line 72

def print_fill_row(pattern)
  print "\r\n".rjust(char_columns + 2, pattern)
end


80
81
82
# File 'app/models/extface/driver/base/print.rb', line 80

def print_ljust_row(text, padstr = ' ', margin=0)
  print "#{text.truncate(char_columns - margin).ljust(char_columns - margin)}\r\n"
end


76
77
78
# File 'app/models/extface/driver/base/print.rb', line 76

def print_rjust_row(text, padstr=' ')
  print "#{text.truncate(char_columns).rjust(char_columns, padstr)}\r\n"
end


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/extface/driver/base/print.rb', line 27

def print_test_page(times = 1)
  device.session("Print Test Page") do |s|
    times.times do |t|
    s.notify "Printing Test Page #{t}"
    s.print "******************************\r\n*"
    s.print "Extface Print Test #{t}".center(28)
    s.print "*\r\n******************************\r\n"

    s.notify "Printing driver information"
    s.print "\r\nDriver:\r\n"
    s.print "------------------------------\r\n"
    s.print "#{self.class::NAME}".truncate(30)
    s.print "\r\n"

    if try(:serial?)
      s.notify "Printing serial settings"
      s.print "\r\nSerial Port Settings:\r\n"
      s.print "------------------------------\r\n"
    end

    s.print "\r\n"
    s.print "------------------------------\r\n"
    s.print Time.now.strftime("Printed on %m/%d/%Y %T\r\n").rjust(32)
    s.print "\r\n\r\n"
    s.notify "Printing finished"
    
    s.try :autocut
    end
  end
end


66
67
68
69
70
# File 'app/models/extface/driver/base/print.rb', line 66

def print_text_price_row(text, price)
  rtext = ("%.2f" % price.to_f)
  lsize = char_columns - rtext.length - 1
  print "#{text.truncate(lsize).ljust(lsize)} #{rtext}\r\n"
end

#printize(bill, detailed = false, payments = true) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/models/extface/driver/base/print.rb', line 88

def printize(bill, detailed = false, payments = true)
  if detailed
    device.session("Fiscal Doc") do |s|
      s.notify "Print Doc Start"
      s.print "******************************\r\n*"
      s.print "Extface Print Bill".center(28)
      s.print "*\r\n******************************\r\n"
      s.notify "Print Sale"
      bill.charges.each do |charge|
      end
    end
  else
    
  end
end