Class: Compendium::AbstractChartProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/compendium/abstract_chart_provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, data_or_url, params = {}, &setup_proc) ⇒ AbstractChartProvider

Returns a new instance of AbstractChartProvider.

Parameters:

  • type (Symbol)

    The type of chart you want to render (:pie, :line, etc). Accepted types might vary by provider.

  • data_or_url (Enumerable or String)

    The data or URL to the data you wish to render. Providers may not support loading data remotely.

  • params (Hash) (defaults to: {})

    If data_or_url is a URL, the params to use for the AJAX request

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/compendium/abstract_chart_provider.rb', line 18

def initialize(type, data_or_url, params = {}, &setup_proc)
  raise NotImplementedError
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)



33
34
35
36
# File 'lib/compendium/abstract_chart_provider.rb', line 33

def method_missing(name, *args, &block)
  return chart.send(name, *args, &block) if chart.respond_to?(name)
  super
end

Instance Attribute Details

#chartObject (readonly)

Returns the value of attribute chart.



11
12
13
# File 'lib/compendium/abstract_chart_provider.rb', line 11

def chart
  @chart
end

Class Method Details

.find_chart_providerObject

Chart providers need to override this method to add a hook for themselves



27
28
29
# File 'lib/compendium/abstract_chart_provider.rb', line 27

def self.find_chart_provider
  nil
end

Instance Method Details

#render(template, container) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/compendium/abstract_chart_provider.rb', line 22

def render(template, container)
  raise NotImplementedError
end