Class: Escpos::Printer
- Inherits:
-
Object
- Object
- Escpos::Printer
- Defined in:
- lib/escpos/printer.rb
Instance Method Summary collapse
- #cut! ⇒ Object
-
#initialize ⇒ Printer
constructor
A new instance of Printer.
- #partial_cut! ⇒ Object
- #save(path) ⇒ Object
- #to_base64 ⇒ Object
- #to_escpos ⇒ Object
- #write(data) ⇒ Object (also: #<<)
Constructor Details
Instance Method Details
#cut! ⇒ Object
22 23 24 |
# File 'lib/escpos/printer.rb', line 22 def cut! @data << Escpos.sequence(PAPER_FULL_CUT) end |
#partial_cut! ⇒ Object
18 19 20 |
# File 'lib/escpos/printer.rb', line 18 def partial_cut! @data << Escpos.sequence(PAPER_PARTIAL_CUT) end |
#save(path) ⇒ Object
26 27 28 29 30 |
# File 'lib/escpos/printer.rb', line 26 def save(path) File.open(path, "wb") do |f| f.print to_escpos end end |
#to_base64 ⇒ Object
36 37 38 |
# File 'lib/escpos/printer.rb', line 36 def to_base64 Base64.strict_encode64 @data end |
#to_escpos ⇒ Object
32 33 34 |
# File 'lib/escpos/printer.rb', line 32 def to_escpos @data end |
#write(data) ⇒ Object Also known as: <<
12 13 14 15 |
# File 'lib/escpos/printer.rb', line 12 def write(data) escpos_data = data.respond_to?(:to_escpos) ? data.to_escpos : data @data << escpos_data.force_encoding("ASCII-8BIT") end |