Class: Thermal::Escpos::Buffer

Inherits:
ByteBuffer show all
Extended by:
Forwardable
Defined in:
lib/thermal/escpos/buffer.rb

Overview

Instance Method Summary collapse

Methods inherited from ByteBuffer

#<<, #buffer, #flush, #flush_base64, #to_a, #to_base64, #to_s

Constructor Details

#initialize(profile) ⇒ Buffer

Returns a new instance of Buffer.



10
11
12
13
14
15
16
17
# File 'lib/thermal/escpos/buffer.rb', line 10

def initialize(profile)
  super()
  @profile = profile
  @codepage = 0
  @charset = 0
  @cjk = false
  init_buffer!
end

Instance Method Details

#current_charsetObject



31
32
33
# File 'lib/thermal/escpos/buffer.rb', line 31

def current_charset
  charsets[@charset]
end

#current_encodingObject



27
28
29
# File 'lib/thermal/escpos/buffer.rb', line 27

def current_encoding
  @cjk ? cjk_encoding : codepages[@codepage]
end

#write_text(text, replace: nil, no_cjk: false) ⇒ Object



35
36
37
38
39
40
# File 'lib/thermal/escpos/buffer.rb', line 35

def write_text(text, replace: nil, no_cjk: false)
  text = ::Thermal::Util.normalize_utf8(text, replace: replace)
  text&.each_codepoint do |u_codepoint|
    write_u_codepoint(u_codepoint, replace: replace, no_cjk: no_cjk)
  end
end