Sha256: b62d115063eed7bbc68c556b56988b3f0a32060f562849c5cc05e1c13058f792

Contents?: true

Size: 671 Bytes

Versions: 12

Compression:

Stored size: 671 Bytes

Contents

class FnordMetric::Dashboard

  attr_accessor :widgets

  def initialize(options={})    
    raise "please provide a :title" unless options[:title]        
    @widgets = Array.new
    @options = options
  end

  def add_widget(w)
    @widgets << w
  end

  def title
    @options[:title]
  end

  def group
    @options[:group] || "Dashboards"
  end

  def token
    token = title.to_s.gsub(/[\W]/, '')
    token = Digest::SHA1.hexdigest(title.to_s) if token.empty?
    token
  end

  def to_json
    {
      :title => title,
      :widgets => {}.tap { |wids|
        @widgets.each do |w|
          wids[w.token] = w.render
        end
      }
    }.to_json
  end
  
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
johnf-fnordmetric-1.2.10 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.9 lib/fnordmetric/web/dashboard.rb
johnf-fnordmetric-1.2.7 lib/fnordmetric/web/dashboard.rb
bp-fnordmetric-1.2.7 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.7 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.6 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.4 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.1 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.2.0 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.0.1 lib/fnordmetric/web/dashboard.rb
fnordmetric-1.0.0 lib/fnordmetric/web/dashboard.rb
fnordmetric-0.9.7 lib/fnordmetric/web/dashboard.rb