class Languages::Zpl2
Public Class Methods
new(data=nil)
click to toggle source
# File lib/languages/zpl2.rb, line 11 def initialize(data=nil) @data = data @document = Zpl2::Document.new @font = Zpl2::Font.new @merge_font = MergeFont.new @position = Zpl2::Position[0,0] @document << @position @document << @merge_font.add({:name => 'B', :height => 15, :width => 15}) end
Public Instance Methods
barcode(*args)
click to toggle source
# File lib/languages/zpl2.rb, line 55 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
data()
click to toggle source
# File lib/languages/zpl2.rb, line 85 def data @data end
document()
click to toggle source
# File lib/languages/zpl2.rb, line 89 def document @document.render end
font(opts={},&block)
click to toggle source
# File lib/languages/zpl2.rb, line 42 def font(opts={},&block) if block_given? @font = @merge_font.add(opts) @document << @font self.instance_eval &block @font = @merge_font.remove @document << @font else @font = Zpl2::Font.new(opts) @document << @font end end
position(x,y,&block)
click to toggle source
# File lib/languages/zpl2.rb, line 68 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
rotate(amount, &block)
click to toggle source
# File lib/languages/zpl2.rb, line 29 def rotate(amount, &block) if block_given? @font = @merge_font.add({:rotation => amount}) @document << @font self.instance_eval &block @font = @merge_font.remove @document << @font else @font.font_rotation amount @document << @font end end
speed(amount)
click to toggle source
# File lib/languages/zpl2.rb, line 81 def speed(amount) @document << Zpl2::Speed.new(amount) end
text(text,opts={})
click to toggle source
# File lib/languages/zpl2.rb, line 21 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