class FnordMetric::Dashboard
Attributes
widgets[RW]
Public Class Methods
new(options={})
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 5 def initialize(options={}) raise "please provide a :title" unless options[:title] @widgets = Array.new @options = options end
Public Instance Methods
add_widget(w)
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 11 def add_widget(w) @widgets << w end
group()
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 19 def group @options[:group] || "Dashboards" end
title()
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 15 def title @options[:title] end
to_json()
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 29 def to_json { :title => title, :widgets => {}.tap { |wids| @widgets.each do |w| wids[w.token] = w.render end } }.to_json end
token()
click to toggle source
# File lib/fnordmetric/web/dashboard.rb, line 23 def token token = title.to_s.gsub(/[\W]/, '') token = Digest::SHA1.hexdigest(title.to_s) if token.empty? token end