Returns the parameter information of this method.
def foo(bar); end method(:foo).parameters #=> [[:req, :bar]] def foo(bar, baz, bat, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:req, :bat], [:block, :blk]] def foo(bar, *args); end method(:foo).parameters #=> [[:req, :bar], [:rest, :args]] def foo(bar, baz, *args, &blk); end method(:foo).parameters #=> [[:req, :bar], [:req, :baz], [:rest, :args], [:block, :blk]]
The name set in Ractor.new
, or nil
.
show the name of the thread.
set given name to the ruby thread. On some platform, it may set the name to pthread and/or kernel.
Path of the file being run
Return the parameters definition of the method or block that the current hook belongs to. Format is the same as for Method#parameters
Returns the system information obtained by uname system call.
The return value is a hash which has 5 keys at least:
:sysname, :nodename, :release, :version, :machine
Example:
require 'etc' require 'pp' pp Etc.uname #=> {:sysname=>"Linux", # :nodename=>"boron", # :release=>"2.6.18-6-xen-686", # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009", # :machine=>"i686"}
Retrieve the PathSupport
object that RubyGems uses to lookup files.
Initialize the filesystem paths to use from env
. env
is a hash-like object (typically ENV
) that is queried for ‘GEM_HOME’, ‘GEM_PATH’, and ‘GEM_SPEC_CACHE’ Keys for the env
hash should be Strings, and values of the hash should be Strings or nil
.
Convert signal number to signal name. Returns nil
if the signo is an invalid signal number.
Signal.trap("INT") { |signo| puts Signal.signame(signo) } Process.kill("INT", 0)
produces:
INT
Returns a string representation of lex_state.
Returns the class for the given object
.
class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class"
See ::trace_object_allocations
for more information and examples.
The number of paths in the +$LOAD_PATH+ from activated gems. Used to prioritize -I
and +ENV+ entries during require
.
Calls the block with each repeated combination of length n
of the elements of self
; each combination is an Array; returns self
. The order of the combinations is indeterminate.
When a block and a positive Integer argument n
are given, calls the block with each n
-tuple repeated combination of the elements of self
. The number of combinations is (n+1)(n+2)/2
.
n
= 1:
a = [0, 1, 2] a.repeated_combination(1) {|combination| p combination }
Output:
[0] [1] [2]
n
= 2:
a.repeated_combination(2) {|combination| p combination }
Output:
[0, 0] [0, 1] [0, 2] [1, 1] [1, 2] [2, 2]
If n
is zero, calls the block once with an empty Array.
If n
is negative, does not call the block:
a.repeated_combination(-1) {|combination| fail 'Cannot happen' }
Returns a new Enumerator if no block given:
a = [0, 1, 2] a.repeated_combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
Using Enumerators, it’s convenient to show the combinations and counts for some values of n
:
e = a.repeated_combination(0) e.size # => 1 e.to_a # => [[]] e = a.repeated_combination(1) e.size # => 3 e.to_a # => [[0], [1], [2]] e = a.repeated_combination(2) e.size # => 6 e.to_a # => [[0, 0], [0, 1], [0, 2], [1, 1], [1, 2], [2, 2]]
Returns the list of private methods accessible to obj. If the all parameter is set to false
, only those methods in the receiver will be listed.
Returns the path parameter passed to dir’s constructor.
d = Dir.new("..") d.path #=> ".."
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. If the given pathname starts with a “~
” it is NOT expanded, it is treated as a normal directory name.
File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
Returns true
if file_name
is an absolute path, and false
otherwise.
File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
Returns the pathname used to create file as a string. Does not normalize the name.
The pathname may not point to the file corresponding to file. For instance, the pathname becomes void when the file has been moved or deleted.
This method raises IOError
for a file created using File::Constants::TMPFILE because they don’t have a pathname.
File.new("testfile").path #=> "testfile" File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
Returns the list of available encoding names.
Encoding.name_list #=> ["US-ASCII", "ASCII-8BIT", "UTF-8", "ISO-8859-1", "Shift_JIS", "EUC-JP", "Windows-31J", "BINARY", "CP932", "eucJP"]