Sha256: f80b96e5299517dc54372c6d71a0b8315eaeb9d0d494f4bb9eca8f0801470da0

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

class FnordMetric::Dashboard

  attr_accessor :widgets, :report

  def initialize(options, _block=nil, &block)
    @options = options.to_options
    @widgets = Array.new
    raise "please provide a :title" unless @options[:title]
    (_block||block).call(self)
    add_report(@options[:report]) if @options[:report]
  end

  def add_widget(w)
    @widgets << (w.is_a?(FnordMetric::Widget) ? w : FnordMetric.widgets.fetch(w))
  end

  def title
    @options[:title]
  end

  def token
    title.to_s.gsub(/[\W]/, '')
  end
  
  def add_report(report)
    @report = report
    @widgets.each{ |w| w.add_report(report) }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fnordmetric-0.3.2 lib/fnordmetric/dashboard.rb