Class: Languages::Zpl2::Barcode1D

Inherits:
Object
  • Object
show all
Defined in:
lib/languages/zpl2/barcode.rb

Constant Summary collapse

BarcodeClasses =
{
 code_128: "BC",
 ean13: "BE"
}

Instance Method Summary collapse

Constructor Details

#initialize(code_type, opts = {}) ⇒ Barcode1D

Returns a new instance of Barcode1D.



20
21
22
23
24
25
# File 'lib/languages/zpl2/barcode.rb', line 20

def initialize(code_type, opts = {})
  @code = BarcodeClasses[code_type]
  @font = opts[:font] || Font.new
  @human_readable = opts[:human_readable] || "Y"
  @text = opts[:text] || ""
end

Instance Method Details

#renderObject



27
28
29
# File 'lib/languages/zpl2/barcode.rb', line 27

def render
  "^#{@code}#{@font.rotation},#{@font.height*2},#{@human_readable},N,N^FD#{@text}^FS"
end