Class: OsCtl::Lib::CGroup::PathReader::Base

Inherits:
Object
  • Object
show all
Includes:
Utils::Humanize
Defined in:
lib/libosctl/cgroup/path_reader.rb

Direct Known Subclasses

V1, V2

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Humanize

#break_interval, #format_long_duration, #format_percent, #format_short_duration, #humanize_data, #humanize_number, #humanize_percent, #humanize_time_ns, #humanize_time_us, #parse_data

Constructor Details

#initializeBase

Returns a new instance of Base.



7
8
9
# File 'lib/libosctl/cgroup/path_reader.rb', line 7

def initialize
  @cache = {}
end

Instance Attribute Details

#cacheObject (readonly, protected)

Returns the value of attribute cache.



13
14
15
# File 'lib/libosctl/cgroup/path_reader.rb', line 13

def cache
  @cache
end

Instance Method Details

#cache_param(path, name) ⇒ Object (protected)



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/libosctl/cgroup/path_reader.rb', line 19

def cache_param(path, name)
  path_cache = cache[path]

  if path_cache
    name_cache = path_cache[name]
    return name_cache if name_cache
  end

  cache[path] ||= {}
  cache[path][name] = yield(path, name)
end

#meminfoObject (protected)



15
16
17
# File 'lib/libosctl/cgroup/path_reader.rb', line 15

def meminfo
  @@meminfo ||= MemInfo.new
end