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 ⇒ Epl2
Returns a new instance of Epl2.
11
12
13
14
15
16
|
# File 'lib/languages/epl2.rb', line 11
def initialize
@document = Epl2::Document.new
@font = Epl2::Font.new
@position = Epl2::Position[0,0]
end
|
Instance Method Details
#barcode(*args) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/languages/epl2.rb', line 54
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
|
#document ⇒ Object
18
19
20
|
# File 'lib/languages/epl2.rb', line 18
def document
@document.render
end
|
#font(opts = {}, &block) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/languages/epl2.rb', line 42
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
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/languages/epl2.rb', line 67
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
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/languages/epl2.rb', line 31
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
22
23
24
25
26
27
28
29
|
# File 'lib/languages/epl2.rb', line 22
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
|