Class: Languages::Zpl2::Barcode2D

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

Constant Summary collapse

BarcodeClasses =
{
 data_matrix: ["X",4,16,16]
}

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Barcode2D.



38
39
40
41
42
# File 'lib/languages/zpl2/barcode.rb', line 38

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

Instance Method Details

#renderObject



44
45
46
# File 'lib/languages/zpl2/barcode.rb', line 44

def render
  "^B#{@code}#{@font.rotation},#{@symbol_height},200,#{@columns_encode},#{@rows_encode}^FD#{@text}^FS"
end