Class: Thermal::Printer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/thermal/printer.rb

Constant Summary collapse

i[ text
hr
bold
underline
align
feed
cut
image
qr_code ].freeze
WRITERS =
[
  ::Thermal::Escpos::Writer,
  ::Thermal::EscposStar::Writer,
  ::Thermal::Stargraphic::Writer,
  ::Thermal::Starprnt::Writer
].freeze
WRITER_MAP =
::Thermal::Util.index_by(WRITERS, &:format).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device, **opts) ⇒ Printer

opts includes :cjk_encoding



30
31
32
33
# File 'lib/thermal/printer.rb', line 30

def initialize(device, **opts)
  @device = device
  @opts = opts
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



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

def device
  @device
end

Instance Method Details

#profileObject



35
36
37
# File 'lib/thermal/printer.rb', line 35

def profile
  @profile ||= ::Thermal::Profile.new(device, **@opts)
end

#writerObject



39
40
41
# File 'lib/thermal/printer.rb', line 39

def writer
  @writer ||= WRITER_MAP[format].new(profile)
end