Tsc::Printer
Inherits Tsc::Command::Status < Tsc::Command::Setup < Tsc::Command::Label < Reference < Object
A Tsc::Printer allows for communicating with a TSC printer over the network.
printer = Tsc::Printer.new("1.2.3.4")
printer.connect do |p|
p.cls
p.direction(0, 0)
p.text(121, 32, "0", 0, 30, 30, 0, "TEST")
p.print(1)
end
Constructors
new(host : String, port : Int32 = 9100)
Creates a new, not-yet-connected printer instance.
# A network printer located at hostname.example.com
printer = Printer.new("hostname.example.com")
# A network printer by IP address
printer = Printer.new("1.2.3.4")
# A network printer by IP address with custom port
printer = Printer.new("1.2.3.4", 56789)
Instance methods
connect
Establishes a connection to the printer.
printer = Printer.new("1.2.3.4")
printer.connect
connect
Establishes a connection to the printer, and yields the printer instance to the block. The connection will be closed automatically when the block returns.
printer = Printer.new("1.2.3.4")
printer.connect do |p|
...
end
disconnect
Closes an established connection to a printer.
printer = Printer.new("1.2.3.4")
printer.connect
...
printer.disconnect
host
Sourcehost=(host : String)
Sourceport
Sourceport=(port : Int32)
Sourcesocket
Sourcesocket=(socket : TCPSocket)
Source