Sha256: f7b7c7054ef56532cb77fed8b275b2ea131ae555c40484a02b00df06bd239be9

Contents?: true

Size: 615 Bytes

Versions: 5

Compression:

Stored size: 615 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 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

5 entries across 5 versions & 1 rubygems

Version Path
fnordmetric-0.7.5 lib/fnordmetric/dashboard.rb
fnordmetric-0.7.4 lib/fnordmetric/dashboard.rb
fnordmetric-0.7.3 lib/fnordmetric/dashboard.rb
fnordmetric-0.7.1 lib/fnordmetric/dashboard.rb
fnordmetric-0.7.0 lib/fnordmetric/dashboard.rb