Class: QueryReport::ChartAdapterModule::ChartAdapter
- Inherits:
-
Object
- Object
- QueryReport::ChartAdapterModule::ChartAdapter
- Defined in:
- lib/query_report/chart_adapter.rb
Instance Attribute Summary collapse
-
#chart ⇒ Object
Returns the value of attribute chart.
-
#chart_type ⇒ Object
Returns the value of attribute chart_type.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(query, records, chart_type, chart_title) ⇒ ChartAdapter
constructor
A new instance of ChartAdapter.
- #sum_with(options) ⇒ Object
Constructor Details
#initialize(query, records, chart_type, chart_title) ⇒ ChartAdapter
Returns a new instance of ChartAdapter.
20 21 22 23 24 25 26 |
# File 'lib/query_report/chart_adapter.rb', line 20 def initialize(query, records, chart_type, chart_title) @query = query @records = records @chart_type = chart_type @chart = "Chartify::#{chart_type.to_s.camelize}Chart".constantize.new @chart.title = chart_title end |
Instance Attribute Details
#chart ⇒ Object
Returns the value of attribute chart.
17 18 19 |
# File 'lib/query_report/chart_adapter.rb', line 17 def chart @chart end |
#chart_type ⇒ Object
Returns the value of attribute chart_type.
17 18 19 |
# File 'lib/query_report/chart_adapter.rb', line 17 def chart_type @chart_type end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
16 17 18 |
# File 'lib/query_report/chart_adapter.rb', line 16 def query @query end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
16 17 18 |
# File 'lib/query_report/chart_adapter.rb', line 16 def records @records end |
Instance Method Details
#sum_with(options) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/query_report/chart_adapter.rb', line 28 def sum_with() @chart.data = [] .each do |column_title, column| @chart.data << [column_title, query.sum(column)] end end |