Class: BTPR880

Inherits:
Thermal::Printer show all
Defined in:
lib/devices/btpr880.rb

Constant Summary collapse

ESC =
27.chr
GS =
29.chr
CODES =
{
  :bold => ESC+"E",
  :underline => ESC+"-",
  :small => ESC+"M",
  :invert => GS+"B",
  :linebreak => "\n"
}
TRANSLATE =
{
  :strong => [CODES[:bold]+"1", CODES[:bold]+"0"],
  :u => [CODES[:underline]+"1", CODES[:underline]+"0"],
  :small => [CODES[:small]+"1", CODES[:small]+"0"],
  :mark => [CODES[:invert]+"1", CODES[:invert]+"0"],
  :br => [CODES[:linebreak], ""]
}

Class Method Summary collapse

Methods inherited from Thermal::Printer

endCode, getCode, startCode

Class Method Details

Yields:

  • (sock)


27
28
29
30
31
# File 'lib/devices/btpr880.rb', line 27

def self.print(ip, port=9001, &block)
  sock = TCPSocket.new(ip, port)
  yield sock if block_given?
  sock.close
end

.translateObject



23
24
25
# File 'lib/devices/btpr880.rb', line 23

def self.translate
  TRANSLATE
end