Class: FnordMetric::Dashboard
- Inherits:
-
Object
- Object
- FnordMetric::Dashboard
- Defined in:
- lib/fnordmetric/web/dashboard.rb
Instance Attribute Summary collapse
-
#widgets ⇒ Object
Returns the value of attribute widgets.
Instance Method Summary collapse
- #add_widget(w) ⇒ Object
- #group ⇒ Object
-
#initialize(options = {}) ⇒ Dashboard
constructor
A new instance of Dashboard.
- #title ⇒ Object
- #to_json ⇒ Object
- #token ⇒ Object
Constructor Details
Instance Attribute Details
#widgets ⇒ Object
Returns the value of attribute widgets.
3 4 5 |
# File 'lib/fnordmetric/web/dashboard.rb', line 3 def @widgets end |
Instance Method Details
#add_widget(w) ⇒ Object
11 12 13 |
# File 'lib/fnordmetric/web/dashboard.rb', line 11 def (w) @widgets << w end |
#group ⇒ Object
19 20 21 |
# File 'lib/fnordmetric/web/dashboard.rb', line 19 def group @options[:group] || "Dashboards" end |
#title ⇒ Object
15 16 17 |
# File 'lib/fnordmetric/web/dashboard.rb', line 15 def title @options[:title] end |
#to_json ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
23 24 25 26 27 |
# 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 |