Class: Dashboards::Element
- Inherits:
-
Object
- Object
- Dashboards::Element
- Defined in:
- lib/dashboards/dsl/element.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, name, options) ⇒ Element
constructor
A new instance of Element.
- #render(context) ⇒ Object
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, ) @type = type @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/dashboards/dsl/element.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/dashboards/dsl/element.rb', line 5 def @options end |
#type ⇒ Object (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 |