Sha256: 0f4080dd1e685c31f606d7fb40b7eab3596973bace516369c209f7a6a231fd2f
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require_relative 'zpl2/font' require_relative 'zpl2/document' require_relative 'zpl2/text' require_relative 'zpl2/position' require_relative 'zpl2/barcode' module Languages class Zpl2 def initialize @document = Zpl2::Document.new @font = Zpl2::Font.new @position = Zpl2::Position[0,0] @document << @position end def text(text,opts={}) if opts.include? :at @document << (@position + Zpl2::Position.from_array(opts[:at])) end @document << Zpl2::Text.new(text) @document << @position if opts.include?(:at) end def rotate(amount, &block) if block_given? @document << Zpl2::Font.new(:rotation => amount) self.instance_eval &block @document << @font else @font.font_rotation amount @document << @font end end def font(opts={},&block) if block_given? @document << Zpl2::Font.new(opts) self.instance_eval &block @document << @font else @font = Zpl2::Font.new(opts) @document << @font end end def barcode(*args) opts = args.extract_options! code,text = args.pop 2 opts = opts.merge({:font => @font,:text => text}) if opts.include? :at @document << (@position + Zpl2::Position.from_array(opts[:at])) end @document << Zpl2::BarcodeFactory.create_barcode(code, opts) end def position(x,y,&block) if block_given? save = @position @position = Zpl2::Position[x,y] @document << @position self.instance_eval(&block) @position = save else @position = Zpl2::Position[x,y] end @document << @position end def document @document.render end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zebra_printer-0.1.1 | lib/languages/zpl2.rb |