app/models/extface/driver/base/print.rb in extface-0.5.6 vs app/models/extface/driver/base/print.rb in extface-0.5.7

- old
+ new

@@ -11,10 +11,12 @@ RAW = true #responds to #push(data) and #pull PRINT = true #POS, slip printers FISCAL = false #cash registers, fiscal printers REPORT = false #only transmit data that must be parsed by handler, CDR, report devices + CHAR_COLUMNS = 30 + #alias_method :print, :push def print(text) if device.encoding.present? push text.encode(device.encoding) else @@ -53,9 +55,35 @@ end end def check_status return true #just pass + end + + def print_edges_row(text1, text2) + print "#{text1} #{text2.rjust(CHAR_COLUMNS - text1.length - 1)}\r\n" + end + + 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 + + def print_fill_row(pattern) + print "\r\n".rjust(CHAR_COLUMNS+2, pattern) + end + + def print_rjust_row(text, padstr=' ') + print "#{text.truncate(CHAR_COLUMNS).rjust(CHAR_COLUMNS, padstr)}\r\n" + end + + def print_ljust_row(text, padstr = ' ', margin=0) + print "#{text.truncate(CHAR_COLUMNS - margin).ljust(CHAR_COLUMNS - margin)}\r\n" + end + + def print_center_row(text, padstr = ' ') + print "#{text.truncate(CHAR_COLUMNS).center(CHAR_COLUMNS, padstr)}\r\n" end def printize(bill, detailed = false, payments = true) if detailed device.session("Fiscal Doc") do |s| \ No newline at end of file