Class: Dashboards::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/dashboards/dsl/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, options) ⇒ Element

Returns a new instance of Element.



7
8
9
10
11
# File 'lib/dashboards/dsl/element.rb', line 7

def initialize(type, name, options)
  @type = type
  @name = name
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/dashboards/dsl/element.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/dashboards/dsl/element.rb', line 5

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/dashboards/dsl/element.rb', line 5

def type
  @type
end

Instance Method Details

#render(context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dashboards/dsl/element.rb', line 13

def render(context)
  case @type
  when :metric
    Metric.new(@name, @options).render(context)
  when :chart
    Chart.new(@name, @options).render(context)
  when :table
    Table.new(@name, @options).render(context)
  else
    raise Error, "Unsupported element type: #{@type}"
  end
end