Iterates the given block for each array of consecutive <n> elements. If no block is given, returns an enumerator.
e.g.:
(1..10).each_cons(3) { |a| p a } # outputs below [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6, 7] [6, 7, 8] [7, 8, 9] [8, 9, 10]
Enters exclusive section.
Returns true if this monitor is locked by any thread
Returns true if this monitor is locked by current thread.
Creates a new MonitorMixin::ConditionVariable
associated with the Monitor
object.
Dump Ruby object
to a JSON
string.
Insert text into the line at the current cursor position.
See GNU Readline’s rl_insert_text function.
Raises NotImplementedError
if the using readline library does not support.
Returns true
if the named file is writable by the real user and group id of this process. See access(3).
Note that some OS-level security features may cause this to return true even though the file is not writable by the real user/group.
If file_name is writable by others, returns an integer representing the file permission bits of file_name. Returns nil
otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
file_name can be an IO
object.
File.world_writable?("/tmp") #=> 511 m = File.world_writable?("/tmp") sprintf("%o", m) #=> "777"
Find
the full path to the executable for gem name
. If the exec_name
is not given, an exception will be raised, otherwise the specified executable’s path is returned. requirements
allows you to specify specific gem versions.
The mode needed to read a file as straight binary.
The path to standard location of the user’s .gemrc file.
Adds a post-installs hook that will be passed a Gem::DependencyInstaller
and a list of installed specifications when Gem::DependencyInstaller#install
is complete
Safely read a file in binary mode on all platforms.
Glob pattern for require-able path suffixes.
Use the home
and paths
values for Gem.dir
and Gem.path
. Used mainly by the unit tests to provide environment isolation.
Default gem load path
Returns whether or not the given entry point func
can be found within lib
. If func
is nil
, the main()
entry point is used by default. If found, it adds the library to list of libraries to be used when linking your extension.
If headers
are provided, it will include those header files as the header files it looks in when searching for func
.
The real name of the library to be linked can be altered by --with-FOOlib
configuration option.
Returns whether or not the entry point func
can be found within the library lib
in one of the paths
specified, where paths
is an array of strings. If func
is nil
, then the main()
function is used as the entry point.
If lib
is found, then the path it was found on is added to the list of library paths searched and linked against.
Returns whether or not the variable var
can be found in the common header files, or within any headers
that you provide. If found, a macro is passed as a preprocessor constant to the compiler using the variable name, in uppercase, prepended with HAVE_
.
To check variables in an additional library, you need to check that library first using have_library()
.
For example, if have_var('foo')
returned true, then the HAVE_FOO
preprocessor macro would be passed to the compiler.
Returns whether or not the constant const
is defined. You may optionally pass the type
of const
as [const, type]
, such as:
have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
You may also pass additional headers
to check against in addition to the common header files, and additional flags to opt
which are then passed along to the compiler.
If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with HAVE_CONST_
.
For example, if have_const('foo')
returned true, then the HAVE_CONST_FOO
preprocessor macro would be passed to the compiler.