Class: Railswatch::Widgets::ResourceChart

Inherits:
Chart
  • Object
show all
Defined in:
lib/railswatch/widgets/resource_chart.rb

Direct Known Subclasses

CPULoad, DiskUsage, MemoryUsage

Instance Attribute Summary collapse

Attributes inherited from Chart

#description, #legend, #subtitle, #units

Attributes inherited from Base

#datasource

Instance Method Summary collapse

Methods inherited from Chart

#to_partial_path

Methods inherited from Base

#to_partial_path

Constructor Details

#initialize(server, key:, type:) ⇒ ResourceChart

Returns a new instance of ResourceChart.



8
9
10
11
12
13
# File 'lib/railswatch/widgets/resource_chart.rb', line 8

def initialize(server, key:, type:, **)
  super(nil)
  @server = server
  @key = key
  @type = type
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/railswatch/widgets/resource_chart.rb', line 6

def key
  @key
end

#serverObject (readonly)

Returns the value of attribute server.



6
7
8
# File 'lib/railswatch/widgets/resource_chart.rb', line 6

def server
  @server
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/railswatch/widgets/resource_chart.rb', line 6

def type
  @type
end

Instance Method Details

#dataObject



19
20
21
22
# File 'lib/railswatch/widgets/resource_chart.rb', line 19

def data
  all_data = server.report.extract_signal { |event| signal(event) }
  all_data[server.key]
end

#format(measurement) ⇒ Object



28
29
30
# File 'lib/railswatch/widgets/resource_chart.rb', line 28

def format(measurement)
  measurement
end

#idObject



15
16
17
# File 'lib/railswatch/widgets/resource_chart.rb', line 15

def id
  [key, 'report', server.key.parameterize].join('_')
end

#signal(event) ⇒ Object



24
25
26
# File 'lib/railswatch/widgets/resource_chart.rb', line 24

def signal(event)
  format(event[key])
end