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
26
# 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] || ""
  @height = opts[:height] || @font.height*2
end

Instance Method Details

#renderObject



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

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