Class: HeapScope::Capabilities

Inherits:
Object
  • Object
show all
Defined in:
lib/heapscope/capabilities.rb

Overview

Runtime capability probe. Never claims unavailable features exist.

Constant Summary collapse

ATTRS =
%i[
  engine
  ruby_version
  allocation_tracing
  reachable_objects
  memsize
  rss_tracking
  each_object
  gc_stat
  dump_all
  object_id_stable_across_restart
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(runtime) ⇒ Capabilities

Returns a new instance of Capabilities.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/heapscope/capabilities.rb', line 21

def initialize(runtime)
  @engine = runtime.engine
  @ruby_version = RUBY_VERSION
  @allocation_tracing = runtime.allocation_tracing?
  @reachable_objects = runtime.reachable_objects?
  @memsize = runtime.memsize?
  @rss_tracking = runtime.rss_tracking?
  @each_object = runtime.each_object?
  @gc_stat = runtime.gc_stat?
  @dump_all = false
  @object_id_stable_across_restart = false
end

Instance Method Details

#to_hObject



34
35
36
# File 'lib/heapscope/capabilities.rb', line 34

def to_h
  ATTRS.to_h { |key| [key, public_send(key)] }
end

#to_sObject



38
39
40
# File 'lib/heapscope/capabilities.rb', line 38

def to_s
  to_h.map { |k, v| "#{k}: #{v}" }.join("\n")
end