Sha256: e50a34107aafc47293e0bffcb3bcfdd064e250fce403a932ac6293afb420c305

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

module PulseMeter
  module Visualize
    class Page
      attr_reader :widgets
      attr_reader :title
      attr_reader :highchart_options

      def initialize(args) 
        raise ArgumentError unless args.respond_to?('[]')
        @title = args[:title] or raise ArgumentError, ":title not specified"
        @widgets = args[:widgets] or raise ArgumentError, ":widgets not specified"
        @highchart_options = args[:highchart_options] or raise ArgumentError, ":highchart_options not specified"
      end

      def widget_data(widget_id)
        widgets[widget_id].data.merge(id: widget_id + 1)
      end

      def widget_datas
        res = []
        widgets.each_with_index do |w, i|
          res << w.data.merge(id: i + 1)
        end
        res
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pulse-meter-0.1.4 lib/pulse-meter/visualize/page.rb
pulse-meter-0.1.3 lib/pulse-meter/visualize/page.rb
pulse-meter-0.1.2 lib/pulse-meter/visualize/page.rb
pulse-meter-0.1.1 lib/pulse-meter/visualize/page.rb
pulse-meter-0.1.0 lib/pulse-meter/visualize/page.rb
pulse-meter-0.0.1 lib/pulse-meter/visualize/page.rb