Class: Malartu::Dashboard

Inherits:
MalartuObject show all
Defined in:
lib/malartu/dashboard.rb

Overview

A dashboard is how you display data within Malartu

Instance Attribute Summary collapse

Attributes inherited from MalartuObject

#json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MalartuObject

paginate?

Constructor Details

#initialize(json) ⇒ Dashboard

Returns a new instance of Dashboard.



5
6
7
8
9
10
11
12
# File 'lib/malartu/dashboard.rb', line 5

def initialize(json)
  super
  define_singleton_method('snapshots') do
    json['snapshots'].map do |c|
      Malartu::Snapshot.new(c)
    end
  end if json['snapshots']
end

Instance Attribute Details

#snapshotsObject

Returns the value of attribute snapshots.



4
5
6
# File 'lib/malartu/dashboard.rb', line 4

def snapshots
  @snapshots
end

Class Method Details

.find(sid) ⇒ Object



14
15
16
17
# File 'lib/malartu/dashboard.rb', line 14

def self.find(sid)
  res = Malartu.request('get', "/kpi/dashboards/#{sid}")
  Malartu::Dashboard.new(res)
end

.listObject



19
20
21
22
23
24
# File 'lib/malartu/dashboard.rb', line 19

def self.list
  res = Malartu.request('get', '/kpi/dashboards')
  res['dashboards'].map do |dashboard|
    Malartu::Dashboard.new(dashboard)
  end
end