Class: Languages::Zpl2::Barcode1D
- Inherits:
-
Object
- Object
- Languages::Zpl2::Barcode1D
- Defined in:
- lib/languages/zpl2/barcode.rb
Constant Summary collapse
- BarcodeClasses =
{ code_128: "BC", ean13: "BE" }
Instance Method Summary collapse
-
#initialize(code_type, opts = {}) ⇒ Barcode1D
constructor
A new instance of Barcode1D.
- #render ⇒ Object
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
#render ⇒ Object
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 |