Class: Compendium::Presenters::Settings::Table
- Inherits:
-
Query
- Object
- Query
- Compendium::Presenters::Settings::Table
show all
- Defined in:
- app/classes/compendium/presenters/settings/table.rb
Instance Attribute Summary collapse
Attributes inherited from Query
#query
Instance Method Summary
collapse
Methods inherited from Query
#method_missing, #update
Constructor Details
#initialize ⇒ Table
Returns a new instance of Table.
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 7
def initialize(*)
super
@headings = {}
number_format '%0.2f'
table_class 'results'
'headings'
row_class 'data'
totals_class 'totals'
skipped_total_cols []
end
|
Instance Attribute Details
#headings ⇒ Object
Returns the value of attribute headings.
5
6
7
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 5
def headings
@headings
end
|
Instance Method Details
38
39
40
41
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 38
def format(column, &block)
@settings[:formatters] ||= {}
@settings[:formatters][column] = block
end
|
43
44
45
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 43
def formatters
(@settings[:formatters] || {})
end
|
#override_heading(*args, &block) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 26
def override_heading(*args, &block)
if block_given?
@headings.each do |key, val|
res = yield val.to_s
@headings[key] = res if res
end
else
col, label = args
@headings[col] = label
end
end
|
#set_headings(headings) ⇒ Object
21
22
23
24
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 21
def set_headings(headings)
headings.map!(&:to_sym)
@headings = Hash[headings.zip(headings)].with_indifferent_access
end
|
#skip_total_for(*cols) ⇒ Object
47
48
49
|
# File 'app/classes/compendium/presenters/settings/table.rb', line 47
def skip_total_for(*cols)
@settings[:skipped_total_cols].concat(cols.map(&:to_sym))
end
|