Class: BrDanfe::CceLib::Document
- Inherits:
-
Object
- Object
- BrDanfe::CceLib::Document
show all
- Defined in:
- lib/br_danfe/cce_lib/document.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Document.
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/br_danfe/cce_lib/document.rb', line 4
def initialize
@document = BrDanfe::DocumentBuilder.build(
page_size: 'A4',
page_layout: :portrait,
left_margin: 30,
right_margin: 30,
top_margin: 30,
botton_margin: 30
)
@document.font 'tinos'
@document.line_width = 0.3
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/br_danfe/cce_lib/document.rb', line 18
def method_missing(method_name, *args, &block)
if @document.respond_to? method_name
@document.send method_name, *args, &block
else
super
end
end
|
Instance Method Details
#box(height:, pad: 5) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/br_danfe/cce_lib/document.rb', line 30
def box(height:, pad: 5)
bounding_box([0, cursor], width: page_width, height: height) do
pad(pad) { indent(pad) { yield if block_given? } }
stroke_bounds
end
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
26
27
28
|
# File 'lib/br_danfe/cce_lib/document.rb', line 26
def respond_to_missing?(method_name, include_private = false)
@document.respond_to?(method_name, include_private) || super
end
|
#text(text, options = {}) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/br_danfe/cce_lib/document.rb', line 37
def text(text, options = {})
pad = options.delete(:pad) || 0
options = { align: :left, size: 12, style: nil }.merge(options)
pad(pad) do
@document.text text, size: options[:size], style: options[:style],
align: options[:align]
end
end
|