class AmCharts::Settings

Public Class Methods

new(hash = {}) click to toggle source
# File lib/amcharts/settings.rb, line 12
def initialize(hash = {})
  @settings = hash.with_indifferent_access
end

Public Instance Methods

function(name, body = nil) click to toggle source
# File lib/amcharts/settings.rb, line 16
def function(name, body = nil)
  ChartBuilder::Function.new(name, body)
end
literal(name) click to toggle source
# File lib/amcharts/settings.rb, line 20
def literal(name)
  ChartBuilder::Literal.new(name)
end
method_missing(name, *args, &block) click to toggle source
# File lib/amcharts/settings.rb, line 24
def method_missing(name, *args, &block)
  if block_given?
    @settings[name] = block.call(*args)
  elsif name.to_s.end_with?('=') && args.length == 1
    prefix = name.to_s.gsub(/=\z/, '')
    @settings[prefix] = args.first
  elsif !args.empty?
    @settings[name] = args.length == 1 ? args.first : args
  elsif name.to_s.end_with?('?')
    prefix = name.to_s.gsub(/\?\z/, '')
    @settings.key?(prefix)
  else
    @settings[name]
  end
end
to_h() click to toggle source
# File lib/amcharts/settings.rb, line 8
def to_h
  @settings
end