Class: PdfTempura::Document::FieldSet
Instance Attribute Summary collapse
Instance Method Summary
collapse
#boxed_characters, #checkbox_field, #field_set, included, #table, #text_field, #with_default_options
Methods included from Validation
included
Constructor Details
#initialize(name, options = {}, &block) ⇒ FieldSet
Returns a new instance of FieldSet.
10
11
12
13
14
15
16
17
|
# File 'lib/pdf_tempura/document/field_set.rb', line 10
def initialize(name, options = {}, &block)
@name = name
@fields = []
@options = options
instance_eval(&block) if block_given?
validate!
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6
7
8
|
# File 'lib/pdf_tempura/document/field_set.rb', line 6
def name
@name
end
|
Instance Method Details
#coordinates ⇒ Object
19
20
21
|
# File 'lib/pdf_tempura/document/field_set.rb', line 19
def coordinates
[x,y]
end
|
#dimensions ⇒ Object
23
24
25
|
# File 'lib/pdf_tempura/document/field_set.rb', line 23
def dimensions
[width,height]
end
|
#height ⇒ Object
40
41
42
43
|
# File 'lib/pdf_tempura/document/field_set.rb', line 40
def height
return 0 if fields.empty?
y - fields.map{ |field| field.y - field.height }.min
end
|
#padding ⇒ Object
45
46
47
|
# File 'lib/pdf_tempura/document/field_set.rb', line 45
def padding
[0,0,0,0]
end
|
#width ⇒ Object
35
36
37
38
|
# File 'lib/pdf_tempura/document/field_set.rb', line 35
def width
return 0 if fields.empty?
fields.map{ |field| field.x + field.width }.max - x
end
|
#x ⇒ Object
27
28
29
|
# File 'lib/pdf_tempura/document/field_set.rb', line 27
def x
fields.map(&:x).min || 0
end
|
#y ⇒ Object
31
32
33
|
# File 'lib/pdf_tempura/document/field_set.rb', line 31
def y
fields.map(&:y).max || 0
end
|