Sha256: 0622634eb1e30196fb2240c1dab4af596e0e5b111c18f1a3754170ab60a96bdb
Contents?: true
Size: 1.4 KB
Versions: 7
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true require 'spout/models/tables/default' require 'spout/models/tables/numeric_vs_choices' require 'spout/models/tables/choices_vs_choices' require 'spout/models/tables/numeric_vs_numeric' require 'spout/models/tables/choices_vs_numeric' module Spout module Models module Tables 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 } 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 def self.get_table_type(variable, chart_variable) "#{variable_to_table_type(variable)}_vs_#{variable_to_table_type(chart_variable)}" end # Identical to graphables, TODO: Refactor 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 end end end
Version data entries
7 entries across 7 versions & 1 rubygems