class Statusboard::WidgetBase
(Abstract) class that represents a widget which can be displayed using the Status Board app. The class must be subclassed for each supported widget type.
Public Class Methods
Public Instance Methods
render()
click to toggle source
Method that renders the specific widget into a (text-)format understandable by the Status Board app.
# File lib/statusboard/widgets/base.rb, line 20 def render raise "Not implemented." end
Protected Instance Methods
render_template(template, locals = {})
click to toggle source
Renders a specified template with the specified local variables in the context of the object itself. The method will search for the template in a subdirectory of the gems VIEW_PATH. The subdirectory will be derived from the class name.
Example:
GraphWidget => views/graph/, TestWidget => views/test/
# File lib/statusboard/widgets/base.rb, line 32 def render_template(template, locals = {}) widget_type = self.class.name.split('::').last.sub(/Widget$/, '').downcase Tilt::ERBTemplate.new(File.join(Statusboard::VIEW_PATH, widget_type, template)).render(self, locals) end