Module: Spout::Models::Tables
- Defined in:
- lib/spout/models/tables.rb,
lib/spout/models/tables/default.rb,
lib/spout/models/tables/choices_vs_choices.rb,
lib/spout/models/tables/choices_vs_numeric.rb,
lib/spout/models/tables/numeric_vs_choices.rb,
lib/spout/models/tables/numeric_vs_numeric.rb
Defined Under Namespace
Classes: ChoicesVsChoices, ChoicesVsNumeric, Default, NumericVsChoices, NumericVsNumeric
Constant Summary collapse
- DEFAULT_CLASS =
Spout::Models::Tables::Default
- GRAPHABLE_CLASSES =
{ "numeric_vs_choices" => Spout::Models::Tables::NumericVsChoices, "choices_vs_choices" => Spout::Models::Tables::ChoicesVsChoices, "numeric_vs_numeric" => Spout::Models::Tables::NumericVsNumeric, "choices_vs_numeric" => Spout::Models::Tables::ChoicesVsNumeric }
Class Method Summary collapse
- .for(variable, chart_variable, subjects, subtitle, totals: true) ⇒ Object
- .get_table_type(variable, chart_variable) ⇒ Object
-
.variable_to_table_type(variable) ⇒ Object
Identical to graphables, TODO: Refactor.
Class Method Details
.for(variable, chart_variable, subjects, subtitle, totals: true) ⇒ Object
20 21 22 23 |
# File 'lib/spout/models/tables.rb', line 20 def self.for(variable, chart_variable, subjects, subtitle, totals: true) table_type = get_table_type(variable, chart_variable) (GRAPHABLE_CLASSES[table_type] || DEFAULT_CLASS).new(variable, chart_variable, subjects, subtitle, totals) end |
.get_table_type(variable, chart_variable) ⇒ Object
25 26 27 |
# File 'lib/spout/models/tables.rb', line 25 def self.get_table_type(variable, chart_variable) "#{variable_to_table_type(variable)}_vs_#{variable_to_table_type(chart_variable)}" end |
.variable_to_table_type(variable) ⇒ Object
Identical to graphables, TODO: Refactor
30 31 32 33 34 35 36 37 38 |
# File 'lib/spout/models/tables.rb', line 30 def self.variable_to_table_type(variable) variable_type = (variable ? variable.type : nil) case variable_type when "numeric", "integer" "numeric" else variable_type end end |