class PiCharts::Config

The Config class provides the interface to the config for a chart. This is basically the skeleton of the infromation that drives the infromation for the chart that can be rendered into json. This information is constructed with its data which actually provides the blueprints.

Attributes

data[RW]

Public Class Methods

new(args={}) click to toggle source

The initialize() method handles the creation of what defines the data for a config, which sets up the relevant base.

# File lib/pi_charts/config.rb, line 14
def initialize(args={})
  @data = {}
  @data[:type] = ''
  @data[:data] = {}
  @data[:data][:datasets] = []
  @data[:options] = {}
end

Public Instance Methods

json() click to toggle source

json() returns the json representation of the config data in a javascript friendly form. Magic!

# File lib/pi_charts/config.rb, line 35
def json
  @data.to_json
end
type() click to toggle source

type() returns the the type set in the config, or false if a type has not yet been set.

# File lib/pi_charts/config.rb, line 29
def type
  @data[:type].empty? ? false : @data[:type]
end
type?() click to toggle source

type?() helps determine if a type has been set or not.

# File lib/pi_charts/config.rb, line 23
def type?
  @data[:type].empty? ? false : true
end