Class: Driver::Base::Print
- Inherits:
-
Extface::Driver
- Object
- Extface::Driver
- Driver::Base::Print
- 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
- PRINT =
responds to #push(data) and #pull
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
- #char_columns ⇒ Object
- #check_status ⇒ Object
-
#print(text) ⇒ Object
alias_method :print, :push.
- #print_center_row(text, padstr = ' ') ⇒ Object
- #print_edges_row(text1, text2) ⇒ Object
- #print_fill_row(pattern) ⇒ Object
- #print_ljust_row(text, padstr = ' ', margin = 0) ⇒ Object
- #print_rjust_row(text, padstr = ' ') ⇒ Object
- #print_test_page(times = 1) ⇒ Object
- #print_text_price_row(text, price) ⇒ Object
- #printize(bill, detailed = false, payments = true) ⇒ Object
Instance Method Details
#char_columns ⇒ Object
104 105 106 |
# File 'app/models/extface/driver/base/print.rb', line 104 def char_columns self.class::CHAR_COLUMNS end |
#check_status ⇒ Object
58 59 60 |
# File 'app/models/extface/driver/base/print.rb', line 58 def check_status return true #just pass end |
#print(text) ⇒ Object
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 |
#print_center_row(text, padstr = ' ') ⇒ Object
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 |
#print_edges_row(text1, text2) ⇒ Object
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 |
#print_fill_row(pattern) ⇒ Object
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 |
#print_ljust_row(text, padstr = ' ', margin = 0) ⇒ Object
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 |
#print_rjust_row(text, padstr = ' ') ⇒ Object
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 |
#print_test_page(times = 1) ⇒ Object
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 |
#print_text_price_row(text, price) ⇒ Object
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 |