Sha256: 9590824a5e64e3b0b5e39865ea1dfce847cc727bf9768d383a041adccb361fcf
Contents?: true
Size: 754 Bytes
Versions: 4
Compression:
Stored size: 754 Bytes
Contents
module Rescpos class Printer attr_reader :socket def initialize(ip, port) @socket = TCPSocket.open(ip, port) @socket.send("\x1b\x40", Socket::MSG_OOB) end def self.open(ip, port) printer = new(ip, port) end def close @socket.close end def print(content, opts={:encoding => 'GBK'}) content = Iconv.iconv("#{opts[:encoding]}//IGNORE","UTF-8//IGNORE", content)[0] @socket.send(content, Socket::MSG_OOB) cut end def print_report(report, opts={}) print(report.render, opts) end private def send_command(command) @socket.send(command, Socket::MSG_OOB) end def cut #TODO send_command("\n\n\n\n\x1b\x69") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rescpos-0.0.7 | lib/rescpos/printer.rb |
rescpos-0.0.6 | lib/rescpos/printer.rb |
rescpos-0.0.5 | lib/rescpos/printer.rb |
rescpos-0.0.3 | lib/rescpos/printer.rb |