Class: Thermal::Starprnt::Writer
Constant Summary
collapse
- DEFAULT_QR_CODE_CELL_SIZE =
4
Constants inherited
from WriterBase
WriterBase::ALIGNMENTS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from WriterBase
#align, #bold, #format, #initialize, #underline
Class Method Details
16
17
18
|
# File 'lib/thermal/starprnt/writer.rb', line 16
def self.format
'starprnt'
end
|
Instance Method Details
#cut ⇒ Object
62
63
64
|
# File 'lib/thermal/starprnt/writer.rb', line 62
def cut
buffer.print(appendCutPaper: 'PartialCut')
end
|
#feed(lines = 1) ⇒ Object
50
51
52
|
# File 'lib/thermal/starprnt/writer.rb', line 50
def feed(lines = 1)
buffer.print(appendLineFeed: lines)
end
|
#hr(style = nil, width: col_width) ⇒ Object
26
27
28
|
# File 'lib/thermal/starprnt/writer.rb', line 26
def hr(style = nil, width: col_width)
write("#{hr_char(style) * width}\n")
end
|
#image(path, opts = {}) ⇒ Object
54
55
56
|
# File 'lib/thermal/starprnt/writer.rb', line 54
def image(path, opts = {})
buffer.print_base64_image(::Escpos::Image.new(path, opts).to_escpos)
end
|
#print(flush: true, output: nil) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/thermal/starprnt/writer.rb', line 8
def print(flush: true, output: nil)
set_utf8_encoding
super
feed(5)
cut
flush ? buffer.flush : buffer.to_a
end
|
#qr_code(url, cell_size = DEFAULT_QR_CODE_CELL_SIZE) ⇒ Object
58
59
60
|
# File 'lib/thermal/starprnt/writer.rb', line 58
def qr_code(url, cell_size = DEFAULT_QR_CODE_CELL_SIZE)
buffer.print(appendQrCode: url, alignment: 'Center', cell: cell_size)
end
|
#text(str, feed: true, replace: nil, **_kwargs) ⇒ Object
20
21
22
23
24
|
# File 'lib/thermal/starprnt/writer.rb', line 20
def text(str, feed: true, replace: nil, **_kwargs)
str = ::Thermal::Util.normalize_utf8(str, replace: replace)
str = "#{str}\n" if feed
write(str) if str
end
|
#write_align! ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/thermal/starprnt/writer.rb', line 38
def write_align!
cmd = case @align
when :right
'Right'
when :center
'Center'
else
'Left'
end
buffer.print(appendAlignment: cmd)
end
|
#write_bold! ⇒ Object
30
31
32
|
# File 'lib/thermal/starprnt/writer.rb', line 30
def write_bold!
buffer.print(enableEmphasis: !!@bold)
end
|
#write_underline! ⇒ Object
34
35
36
|
# File 'lib/thermal/starprnt/writer.rb', line 34
def write_underline!
buffer.print(enableUnderline: !!@underline)
end
|