Class: AmCharts::ChartBuilder::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/amcharts/chart_builder/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, body = nil) ⇒ Function

Returns a new instance of Function.



6
7
8
# File 'lib/amcharts/chart_builder/function.rb', line 6

def initialize(name, body = nil)
  @name, @body = name, body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/amcharts/chart_builder/function.rb', line 4

def body
  @body
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/amcharts/chart_builder/function.rb', line 4

def name
  @name
end

Instance Method Details

#to_jsonObject



10
11
12
# File 'lib/amcharts/chart_builder/function.rb', line 10

def to_json
  body.nil? ? name.to_s : "function #{name}() { #{body} }"
end