Class: Languages::Epl2
- Inherits:
-
Object
show all
- Defined in:
- lib/languages/epl2.rb,
lib/languages/epl2/font.rb,
lib/languages/epl2/text.rb,
lib/languages/epl2/barcode.rb,
lib/languages/epl2/document.rb,
lib/languages/epl2/position.rb
Defined Under Namespace
Classes: Barcode1D, Barcode2D, BarcodeFactory, Document, Font, Position, Text
Instance Method Summary
collapse
Constructor Details
#initialize(data = nil) ⇒ Epl2
Returns a new instance of Epl2.
Instance Method Details
#barcode(*args) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/languages/epl2.rb', line 55
def barcode(*args)
opts = args.
code,text = args.pop 2
opts = opts.merge({:font => font,:text =>text})
if opts.include? :at
opts[:at] = (@position + Epl2::Position.from_array(opts[:at])).to_a
end
b = Epl2::BarcodeFactory.create_barcode code,opts
@document << b.render
end
|
#data ⇒ Object
79
80
81
|
# File 'lib/languages/epl2.rb', line 79
def data
@data
end
|
#document ⇒ Object
19
20
21
|
# File 'lib/languages/epl2.rb', line 19
def document
@document.render
end
|
#font(opts = {}, &block) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/languages/epl2.rb', line 43
def font(opts={},&block)
if opts.include? :size
@font = Epl2::Font.new(opts)
end
if block_given?
save = @font
@font = Epl2::Font.new(opts)
self.instance_eval(&block)
@font = save
end
end
|
#position(x, y, &block) ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/languages/epl2.rb', line 68
def position(x,y,&block)
if block_given?
save = @position
@position = Epl2::Position[x,y]
self.instance_eval(&block)
@position = save
else
@position = Epl2::Position[x,y]
end
end
|
#rotate(amount, &block) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/languages/epl2.rb', line 32
def rotate(amount,&block)
if block_given?
save = @font
@font.font_rotation amount
self.instance_eval(&block)
@font = save
else
@font.font_rotation amount
end
end
|
#text(value, opts = {}) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/languages/epl2.rb', line 23
def text(value,opts={})
if opts.include? :at
opts[:at] = (@position + Epl2::Position.from_array(opts[:at])).to_a
else
opts[:at] = @position.to_a
end
@document << Epl2::Text.new(:font => @font, :at => opts[:at], :text => value)
end
|