Sha256: bab619951837b68d3609c07e94b0df7ced36781c9c7dca081a0033777f28b699

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module PulseMeter
  module Visualize
    class Layout
      attr_reader :pages

      attr_reader :title
      attr_reader :use_utc
      attr_reader :outlier_color
      attr_reader :highchart_options

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

      def to_app
        PulseMeter::Visualize::App.new(self)
      end

			def page_infos
				res = []
				pages.each_with_index do |p, i|
					res << {
						id: i + 1,
						title: p.title,
            highchart_options: p.highchart_options
					}
				end
				res
			end

			def options
				{
					use_utc: @use_utc,
				  outlier_color: @outlier_color,
          highchart_options: @highchart_options
        }
      end

      def widget(page_id, widget_id)
        pages[page_id].widget_data(widget_id)
      end

      def widgets(page_id)
        pages[page_id].widget_datas
      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/layout.rb
pulse-meter-0.1.3 lib/pulse-meter/visualize/layout.rb
pulse-meter-0.1.2 lib/pulse-meter/visualize/layout.rb
pulse-meter-0.1.1 lib/pulse-meter/visualize/layout.rb
pulse-meter-0.1.0 lib/pulse-meter/visualize/layout.rb
pulse-meter-0.0.1 lib/pulse-meter/visualize/layout.rb