Class: OsCtl::Lib::SysConf

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/libosctl/sys_conf.rb

Constant Summary collapse

VALUES =
%i[page_size tics_per_second].freeze

Instance Method Summary collapse

Constructor Details

#initializeSysConf

Returns a new instance of SysConf.



16
17
18
# File 'lib/libosctl/sys_conf.rb', line 16

def initialize
  @values = {}
end

Instance Method Details

#get(name) ⇒ Object

Parameters:

  • name (Symbol)


21
22
23
24
25
26
27
# File 'lib/libosctl/sys_conf.rb', line 21

def get(name)
  unless VALUES.include?(name)
    raise ArgumentError, "#{name.inspect} is not known"
  end

  @values[name] ||= send(:"get_#{name}")
end

#get_page_sizeObject (protected)



35
36
37
# File 'lib/libosctl/sys_conf.rb', line 35

def get_page_size
  Etc.sysconf(Etc::SC_PAGESIZE)
end

#get_tics_per_secondObject (protected)



39
40
41
# File 'lib/libosctl/sys_conf.rb', line 39

def get_tics_per_second
  Etc.sysconf(Etc::SC_CLK_TCK)
end