Class: GoogleChart::AbstractChart
- Inherits:
-
Object
- Object
- GoogleChart::AbstractChart
- Defined in:
- lib/google_chart/abstract_chart.rb
Constant Summary collapse
- @@base_url =
'http://chart.apis.google.com/chart'
- @@default_size =
'600x500'
Instance Attribute Summary collapse
Class Method Summary collapse
- .inherited(klass) ⇒ Object
- .register!(*parameters) ⇒ Object
- .registered?(parameter) ⇒ Boolean
- .registry ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) {|_self| ... } ⇒ AbstractChart
constructor
A new instance of AbstractChart.
- #to_url ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ AbstractChart
Returns a new instance of AbstractChart.
6 7 8 9 |
# File 'lib/google_chart/abstract_chart.rb', line 6 def initialize( = {}) .each {|key, value| send("#{key}=", value) } yield self if block_given? end |
Instance Attribute Details
#size ⇒ Object
17 18 19 20 |
# File 'lib/google_chart/abstract_chart.rb', line 17 def size @size ||= @@default_size "chs=#{@size}" end |
Class Method Details
.inherited(klass) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/google_chart/abstract_chart.rb', line 22 def self.inherited(klass) klass.class_eval do class_variable_set(:@@parameters, []) register!(:chart_type, :size) end end |
.register!(*parameters) ⇒ Object
29 30 31 32 33 |
# File 'lib/google_chart/abstract_chart.rb', line 29 def self.register!(*parameters) parameters.each do |parameter| registry.push(parameter) unless registered?(parameter) end end |
.registered?(parameter) ⇒ Boolean
35 36 37 |
# File 'lib/google_chart/abstract_chart.rb', line 35 def self.registered?(parameter) registry.include?(parameter) end |
.registry ⇒ Object
39 40 41 |
# File 'lib/google_chart/abstract_chart.rb', line 39 def self.registry class_variable_get :@@parameters end |
Instance Method Details
#to_url ⇒ Object
11 12 13 |
# File 'lib/google_chart/abstract_chart.rb', line 11 def to_url "#{@@base_url}?#{query_string}" end |