Returns a pretty printed object as a string.
In order to use this method you must first require the PP
module:
require 'pp'
See the PP
module for more information.
Returns an array containing elements selected by the block.
With a block given, calls the block with successive elements; returns an array of those elements for which the block returns a truthy value:
(0..9).select {|element| element % 3 == 0 } # => [0, 3, 6, 9] a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') } a # => {:bar=>1, :baz=>2}
With no block given, returns an Enumerator.
Related: reject
.
Returns an array containing truthy elements returned by the block.
With a block given, calls the block with successive elements; returns an array containing each truthy value returned by the block:
(0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16] {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz]
When no block given, returns an Enumerator.
Returns an array of flattened objects returned by the block.
With a block given, calls the block with successive elements; returns a flattened array of objects returned by the block:
[0, 1, 2, 3].flat_map {|element| -element } # => [0, -1, -2, -3] [0, 1, 2, 3].flat_map {|element| [element, -element] } # => [0, 0, 1, -1, 2, -2, 3, -3] [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100] {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2]
With no block given, returns an Enumerator.
Alias: collect_concat
.
Initializes the MonitorMixin
after being included in a class or when an object has been extended with the MonitorMixin
Returns the original line from source for from the given object
.
See ::trace_object_allocations
for more information and examples.
Returns the full line that is being edited. This is useful from within the complete_proc for determining the context of the completion request.
The length of Readline.line_buffer
and GNU Readline’s rl_end are same.
Raises NotImplementedError
if the using readline library does not support.
Clear the current input line.
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.
Combine two Adler-32 check values in to one. adler1
is the first Adler-32 value, adler2
is the second Adler-32 value. len2
is the length of the string used to generate adler2
.
Combine two CRC-32 check values in to one. crc1
is the first CRC-32 value, crc2
is the second CRC-32 value. len2
is the length of the string used to generate crc2
.
Returns the number of malloc() allocations.
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
Returns true if using experimental feature Variable Width Allocation, false otherwise.
Creates hard links; returns nil
.
Arguments src
and dest
should be interpretable as paths.
If src
is the path to a file and dest
does not exist, creates a hard link at dest
pointing to src
:
FileUtils.touch('src0.txt') File.exist?('dest0.txt') # => false FileUtils.link_entry('src0.txt', 'dest0.txt') File.file?('dest0.txt') # => true
If src
is the path to a directory and dest
does not exist, recursively creates hard links at dest
pointing to paths in src
:
FileUtils.mkdir_p(['src1/dir0', 'src1/dir1']) src_file_paths = [ 'src1/dir0/t0.txt', 'src1/dir0/t1.txt', 'src1/dir1/t2.txt', 'src1/dir1/t3.txt', ] FileUtils.touch(src_file_paths) File.directory?('dest1') # => true FileUtils.link_entry('src1', 'dest1') File.file?('dest1/dir0/t0.txt') # => true File.file?('dest1/dir0/t1.txt') # => true File.file?('dest1/dir1/t2.txt') # => true File.file?('dest1/dir1/t3.txt') # => true
Keyword arguments:
dereference_root: true
- dereferences src
if it is a symbolic link.
remove_destination: true
- removes dest
before creating links.
Raises an exception if dest
is the path to an existing file or directory and keyword argument remove_destination: true
is not given.
Related: FileUtils.ln
(has different options).
Creates hard links; returns nil
.
Arguments src
and dest
should be interpretable as paths.
If src
is the path to a file and dest
does not exist, creates a hard link at dest
pointing to src
:
FileUtils.touch('src0.txt') File.exist?('dest0.txt') # => false FileUtils.link_entry('src0.txt', 'dest0.txt') File.file?('dest0.txt') # => true
If src
is the path to a directory and dest
does not exist, recursively creates hard links at dest
pointing to paths in src
:
FileUtils.mkdir_p(['src1/dir0', 'src1/dir1']) src_file_paths = [ 'src1/dir0/t0.txt', 'src1/dir0/t1.txt', 'src1/dir1/t2.txt', 'src1/dir1/t3.txt', ] FileUtils.touch(src_file_paths) File.directory?('dest1') # => true FileUtils.link_entry('src1', 'dest1') File.file?('dest1/dir0/t0.txt') # => true File.file?('dest1/dir0/t1.txt') # => true File.file?('dest1/dir1/t2.txt') # => true File.file?('dest1/dir1/t3.txt') # => true
Keyword arguments:
dereference_root: true
- dereferences src
if it is a symbolic link.
remove_destination: true
- removes dest
before creating links.
Raises an exception if dest
is the path to an existing file or directory and keyword argument remove_destination: true
is not given.
Related: FileUtils.ln
(has different options).
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names, instance variable names, or constant names (see def_delegator
). The value is the accessor to which the methods will be delegated.
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names. The value is the accessor to which the methods will be delegated.
Returns whether or not macro
is defined either in the common header files or within any headers
you provide.
Any options you pass to opt
are passed along to the compiler.
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.
Instructs mkmf to search for the given header
in any of the paths
provided, and returns whether or not it was found in those paths.
If the header is found then the path it was found on is added to the list of included directories that are sent to the compiler (via the -I
switch).