Class: Proforma::Modeling::DataTable::Column
Overview
An explicit table column that understands how to compile header, body, and footer cells from records.
Constant Summary
Types::Align::CENTER, Types::Align::LEFT, Types::Align::RIGHT
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(align: LEFT, body: '', footer: '', header: '', width: nil) ⇒ Column
Returns a new instance of Column.
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/proforma/modeling/data_table/column.rb', line 26
def initialize(
align: LEFT,
body: '',
footer: '',
header: '',
width: nil
)
@align = align
@body = body
@footer =
@header =
@width = width
end
|
Instance Attribute Details
#align ⇒ Object
40
41
42
|
# File 'lib/proforma/modeling/data_table/column.rb', line 40
def align
@align || LEFT
end
|
#body ⇒ Object
44
45
46
|
# File 'lib/proforma/modeling/data_table/column.rb', line 44
def body
@body.to_s
end
|
48
49
50
|
# File 'lib/proforma/modeling/data_table/column.rb', line 48
def
@footer.to_s
end
|
52
53
54
|
# File 'lib/proforma/modeling/data_table/column.rb', line 52
def
@header.to_s
end
|
#width ⇒ Object
56
57
58
|
# File 'lib/proforma/modeling/data_table/column.rb', line 56
def width
@width ? @width.to_f : nil
end
|
Instance Method Details
#compile_body_cell(record, evaluator) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/proforma/modeling/data_table/column.rb', line 68
def compile_body_cell(record, evaluator)
Modeling::Table::Cell.new(
align: align,
text: evaluator.text(record, body),
width: width
)
end
|
76
77
78
79
80
81
82
|
# File 'lib/proforma/modeling/data_table/column.rb', line 76
def (record, evaluator)
Modeling::Table::Cell.new(
align: align,
text: evaluator.text(record, ),
width: width
)
end
|
60
61
62
63
64
65
66
|
# File 'lib/proforma/modeling/data_table/column.rb', line 60
def (record, evaluator)
Modeling::Table::Cell.new(
align: align,
text: evaluator.text(record, ),
width: width
)
end
|
84
85
86
|
# File 'lib/proforma/modeling/data_table/column.rb', line 84
def
!.to_s.empty?
end
|
88
89
90
|
# File 'lib/proforma/modeling/data_table/column.rb', line 88
def
!.to_s.empty?
end
|