module RbConfig
The module storing Ruby interpreter configurations on building.
This file was created by mkconfig.rb when ruby was built. It contains build information for ruby which is used e.g. by mkmf to build compatible native extensions. Any changes made to this file will be lost the next time ruby is built.
Constants
- CONFIG
-
The hash configurations stored.
- DESTDIR
-
DESTDIR
on make install. - LIMITS
-
A
Hash
with the bounds of numeric types available to the C compiler used to build Ruby. To access this constant, first runrequire 'rbconfig/sizeof'
.require 'rbconfig/sizeof' RUBY_PLATFORM # => "x64-mingw-ucrt" RbConfig::LIMITS.fetch_values('FIXNUM_MAX', 'LONG_MAX') # => [1073741823, 2147483647]
- MAKEFILE_CONFIG
-
Almost same with
CONFIG
.MAKEFILE_CONFIG
has other variable reference like below.MAKEFILE_CONFIG["bindir"] = "$(exec_prefix)/bin"
The values of this constant is used for creating Makefile.
require 'rbconfig' print <<-END_OF_MAKEFILE prefix = #{RbConfig::MAKEFILE_CONFIG['prefix']} exec_prefix = #{RbConfig::MAKEFILE_CONFIG['exec_prefix']} bindir = #{RbConfig::MAKEFILE_CONFIG['bindir']} END_OF_MAKEFILE => prefix = /usr/local exec_prefix = $(prefix) bindir = $(exec_prefix)/bin MAKEFILE_CONFIG = {}
RbConfig.expand
is used for resolving references like above in rbconfig.require 'rbconfig' p RbConfig.expand(RbConfig::MAKEFILE_CONFIG["bindir"]) # => "/usr/local/bin"
- SIZEOF
-
A
Hash
with the byte size of C types available to the compiler used to build Ruby. To access this constant, first runrequire 'rbconfig/sizeof'
.require 'rbconfig/sizeof' RUBY_PLATFORM # => "x64-mingw-ucrt" RbConfig::SIZEOF.fetch_values('long', 'void*') # => [4, 8]
- TOPDIR
-
Ruby installed directory.
Public Class Methods
Source
# File rbconfig.rb, line 301 def RbConfig::expand(val, config = CONFIG) newval = val.gsub(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) { var = $& if !(v = $1 || $2) '$' elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]] pat, sub = $1, $2 config[v] = false config[v] = RbConfig::expand(key, config) key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat key else var end } val.replace(newval) unless newval == val val end
RbConfig.expand(val) -> string RbConfig.expand(val, config) -> string
expands variable with given val
value.
RbConfig.expand("$(bindir)") # => /home/foobar/all-ruby/ruby19x/bin
Source
# File rbconfig.rb, line 359 def RbConfig.ruby File.join( RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"] ) end
RbConfig.ruby -> path
returns the absolute pathname of the ruby command.