Class: TableStructure::Table
- Inherits:
-
Object
- Object
- TableStructure::Table
show all
- Defined in:
- lib/table_structure/table.rb
Defined Under Namespace
Classes: ColumnConverter, ContextBuilder, Iterator, RowBuilder
Instance Method Summary
collapse
Constructor Details
#initialize(schema, row_type: :array) {|_self| ... } ⇒ Table
Returns a new instance of Table.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/table_structure/table.rb', line 5
def initialize(schema, row_type: :array)
@columns = schema.columns
@context = schema.context
@key_converter = schema.key_converter
ContextBuilder.create_module(
schema.context_builders,
apply_to_name: schema.contain_callable?(:name),
apply_to_value: schema.contain_callable?(:value),
context: schema.context
) { |mod| extend mod }
ColumnConverter.create_module(
schema.column_converters,
context: schema.context
) { |mod| extend mod }
RowBuilder.create_module(
schema.row_builders,
row_type: row_type,
keys: keys,
context: schema.context
) { |mod| extend mod }
yield self if block_given?
end
|
Instance Method Details
#body(items) ⇒ Object
36
37
38
39
40
|
# File 'lib/table_structure/table.rb', line 36
def body(items)
Enumerator.new do |y|
items.each { |item| y << data(context: item) }
end
end
|
32
33
34
|
# File 'lib/table_structure/table.rb', line 32
def (context: nil)
row_values(:names, context)
end
|
#row(context: nil) ⇒ Object
47
48
49
50
|
# File 'lib/table_structure/table.rb', line 47
def row(context: nil)
warn '[TableStructure] `TableStructure::Table#row(context: ...)` has been deprecated. Use `TableStructure::Table#body(items)` instead.'
data(context: context)
end
|
#rows(items) ⇒ Object
42
43
44
45
|
# File 'lib/table_structure/table.rb', line 42
def rows(items)
warn '[TableStructure] `TableStructure::Table#rows(items)` has been deprecated. Use `TableStructure::Table#body(items)` instead.'
body(items)
end
|