Removes the definition of the sym, returning that constant’s value.
class Dummy @@var = 99 puts @@var remove_class_variable(:@@var) p(defined? @@var) end
produces:
99 nil
Returns the value of the given class variable (or throws a NameError
exception). The @@
part of the variable name should be included for regular class variables. String arguments are converted to symbols.
class Fred @@foo = 99 end Fred.class_variable_get(:@@foo) #=> 99
Sets the class variable named by symbol to the given object. If the class variable name is passed as a string, that string is converted to a symbol.
class Fred @@foo = 99 def foo @@foo end end Fred.class_variable_set(:@@foo, 101) #=> 101 Fred.new.foo #=> 101
Returns true
if the given class variable is defined in obj. String arguments are converted to symbols.
class Fred @@foo = 99 end Fred.class_variable_defined?(:@@foo) #=> true Fred.class_variable_defined?(:@@bar) #=> false
Returns true
if the named private method is defined by _ mod_ (or its included modules and, if mod is a class, its ancestors). String arguments are converted to symbols.
module A def method1() end end class B private def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.private_method_defined? "method1" #=> false C.private_method_defined? "method2" #=> true C.method_defined? "method2" #=> false
Makes existing class methods private. Often used to hide the default constructor new
.
String arguments are converted to symbols.
class SimpleSingleton # Not thread safe private_class_method :new def SimpleSingleton.create(*args, &block) @me = new(*args, &block) if ! @me @me end end
Re-composes a prime factorization and returns the product.
See Prime#int_from_prime_division
for more details.
Returns detail information of return value type of method. The information is array.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]
Returns the array of WIN32OLE_TYPE
object which is implemented by the WIN32OLE_TYPE
object and having IMPLTYPEFLAG_FSOURCE.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.source_ole_types # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]
Returns the array of WIN32OLE_TYPE
object which is implemented by the WIN32OLE_TYPE
object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer") p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
Re-composes a prime factorization and returns the product.
See Prime#int_from_prime_division
for more details.
Task
description for the clobber rdoc task or its renamed equivalent
Task
description for the rdoc task or its renamed equivalent
Task
description for the rerdoc task or its renamed description
Returns the value of a thread local variable that has been set. Note that these are different than fiber local values. For fiber local values, please see Thread#[]
and Thread#[]=
.
Thread
local values are carried along with threads, and do not respect fibers. For example:
Thread.new { Thread.current.thread_variable_set("foo", "bar") # set a thread local Thread.current["foo"] = "bar" # set a fiber local Fiber.new { Fiber.yield [ Thread.current.thread_variable_get("foo"), # get the thread local Thread.current["foo"], # get the fiber local ] }.resume }.join.value # => ['bar', nil]
The value “bar” is returned for the thread local, where nil is returned for the fiber local. The fiber is executed in the same thread, so the thread local values are available.
Sets a thread local with key
to value
. Note that these are local to threads, and not to fibers. Please see Thread#thread_variable_get
and Thread#[]
for more information.
Returns the value of the local variable symbol
.
def foo a = 1 binding.local_variable_get(:a) #=> 1 binding.local_variable_get(:b) #=> NameError end
This method is the short version of the following code:
binding.eval("#{symbol}")
Set
local variable named symbol
as obj
.
def foo a = 1 bind = binding bind.local_variable_set(:a, 2) # set existing local variable `a' bind.local_variable_set(:b, 3) # create new local variable `b' # `b' exists only in binding p bind.local_variable_get(:a) #=> 2 p bind.local_variable_get(:b) #=> 3 p a #=> 2 p b #=> NameError end
This method behaves similarly to the following code:
binding.eval("#{symbol} = #{obj}")
if obj
can be dumped in Ruby code.
Returns true
if a local variable symbol
exists.
def foo a = 1 binding.local_variable_defined?(:a) #=> true binding.local_variable_defined?(:b) #=> false end
This method is the short version of the following code:
binding.eval("defined?(#{symbol}) == 'local-variable'")
The Kernel#require
from before RubyGems was loaded.
Verify internal consistency.
This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.
This method removes a file system entry path
. path
shall be a regular file, a directory, or something. If path
is a directory, remove it recursively. This method is required to avoid TOCTTOU (time-of-check-to-time-of-use) local security vulnerability of rm_r
. rm_r
causes security hole when:
* Parent directory is world writable (including /tmp). * Removing directory tree includes world writable directory. * The system has symbolic link.
To avoid this security hole, this method applies special preprocess. If path
is a directory, this method chown(2) and chmod(2) all removing directories. This requires the current process is the owner of the removing whole directory tree, or is the super user (root).
WARNING: You must ensure that ALL parent directories cannot be moved by other untrusted users. For example, parent directories should not be owned by untrusted users, and should not be world writable except when the sticky bit set.
WARNING: Only the owner of the removing directory tree, or Unix super user (root) should invoke this method. Otherwise this method does not work.
For details of this security vulnerability, see Perl’s case:
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448 http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
This method removes a file system entry path
. path
shall be a regular file, a directory, or something. If path
is a directory, remove it recursively. This method is required to avoid TOCTTOU (time-of-check-to-time-of-use) local security vulnerability of rm_r
. rm_r
causes security hole when:
* Parent directory is world writable (including /tmp). * Removing directory tree includes world writable directory. * The system has symbolic link.
To avoid this security hole, this method applies special preprocess. If path
is a directory, this method chown(2) and chmod(2) all removing directories. This requires the current process is the owner of the removing whole directory tree, or is the super user (root).
WARNING: You must ensure that ALL parent directories cannot be moved by other untrusted users. For example, parent directories should not be owned by untrusted users, and should not be world writable except when the sticky bit set.
WARNING: Only the owner of the removing directory tree, or Unix super user (root) should invoke this method. Otherwise this method does not work.
For details of this security vulnerability, see Perl’s case:
http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448 http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
Canonical Ordering