Class: PulseMeter::Visualize::Page

Inherits:
Base
  • Object
show all
Defined in:
lib/pulse-meter/visualize/page.rb

Instance Method Summary collapse

Methods inherited from Base

#method_missing

Constructor Details

#initialize(opts) ⇒ Page

Returns a new instance of Page.



4
5
6
7
8
# File 'lib/pulse-meter/visualize/page.rb', line 4

def initialize(opts)
  super
  @opts[:widgets] ||= []
  @opts[:gchart_options] ||= {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PulseMeter::Visualize::Base

Instance Method Details

#widget_data(widget_id, opts = {}) ⇒ Object



10
11
12
# File 'lib/pulse-meter/visualize/page.rb', line 10

def widget_data(widget_id, opts = {})
  widgets[widget_id].data(opts).merge(id: widget_id + 1)
end

#widget_datasObject



14
15
16
17
18
19
20
# File 'lib/pulse-meter/visualize/page.rb', line 14

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