Class: Proforma::Modeling::DataTable
- Inherits:
-
Object
- Object
- Proforma::Modeling::DataTable
- Includes:
- Compiling::Compilable
- Defined in:
- lib/proforma/modeling/data_table.rb,
lib/proforma/modeling/data_table/column.rb,
lib/proforma/modeling/data_table/aggregator.rb
Overview
A table that understands how to be compiled against a data source.
Defined Under Namespace
Classes: Aggregator, Column
Instance Attribute Summary collapse
- #aggregators ⇒ Object
- #columns ⇒ Object
- #empty_message ⇒ Object
-
#property ⇒ Object
Returns the value of attribute property.
Instance Method Summary collapse
- #compile(data, evaluator) ⇒ Object
-
#initialize(aggregators: [], columns: [], empty_message: '', property: nil) ⇒ DataTable
constructor
A new instance of DataTable.
Constructor Details
#initialize(aggregators: [], columns: [], empty_message: '', property: nil) ⇒ DataTable
Returns a new instance of DataTable.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/proforma/modeling/data_table.rb', line 26 def initialize( aggregators: [], columns: [], empty_message: '', property: nil ) @aggregators = Aggregator.array(aggregators) @columns = Column.array(columns) @empty_message = @property = property end |
Instance Attribute Details
#aggregators ⇒ Object
42 43 44 |
# File 'lib/proforma/modeling/data_table.rb', line 42 def aggregators Array(@aggregators) end |
#columns ⇒ Object
46 47 48 |
# File 'lib/proforma/modeling/data_table.rb', line 46 def columns Array(@columns) end |
#empty_message ⇒ Object
38 39 40 |
# File 'lib/proforma/modeling/data_table.rb', line 38 def @empty_message.to_s end |
#property ⇒ Object
Returns the value of attribute property.
20 21 22 |
# File 'lib/proforma/modeling/data_table.rb', line 20 def property @property end |
Instance Method Details
#compile(data, evaluator) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/proforma/modeling/data_table.rb', line 50 def compile(data, evaluator) records = array(evaluator.value(data, property)) return Text.new(value: ) if (records) = (records, evaluator) Table.new( body: make_body(records, evaluator), footer: (, evaluator), header: make_header({}, evaluator) ) end |