Set
the effective user ID, and if possible, the saved user ID of the process to the given user. Returns the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0] Process::UID.grant_privilege(31) #=> 31 [Process.uid, Process.euid] #=> [0, 31]
Change the current process’s real and effective group ID to that specified by group. Returns the new group ID. Not available on all platforms.
[Process.gid, Process.egid] #=> [0, 0] Process::GID.change_privilege(33) #=> 33 [Process.gid, Process.egid] #=> [33, 33]
Set
the effective group ID, and if possible, the saved group ID of the process to the given group. Returns the new effective group ID. Not available on all platforms.
[Process.gid, Process.egid] #=> [0, 0] Process::GID.grant_privilege(31) #=> 33 [Process.gid, Process.egid] #=> [0, 33]
Writes data
onto the IO
, raising a FileOverflow
exception if the number of bytes will be more than limit
Writes data
onto the IO
Returns the value of the given instance variable, or nil if the instance variable is not set. The @
part of the variable name should be included for regular instance variables. Throws a NameError
exception if the supplied symbol is not valid as an instance variable name. String arguments are converted to symbols.
class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_get(:@a) #=> "cat" fred.instance_variable_get("@b") #=> 99
Sets the instance variable named by symbol to the given object, thereby frustrating the efforts of the class’s author to attempt to provide proper encapsulation. The variable does not have to exist prior to this call. If the instance variable name is passed as a string, that string is converted to a symbol.
class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_set(:@a, 'dog') #=> "dog" fred.instance_variable_set(:@c, 'cat') #=> "cat" fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
Returns true
if the given instance variable is defined in obj. String arguments are converted to symbols.
class Fred def initialize(p1, p2) @a, @b = p1, p2 end end fred = Fred.new('cat', 99) fred.instance_variable_defined?(:@a) #=> true fred.instance_variable_defined?("@b") #=> true fred.instance_variable_defined?("@c") #=> false
Removes the named instance variable from obj, returning that variable’s value.
class Dummy attr_reader :var def initialize @var = 99 end def remove remove_instance_variable(:@var) end end d = Dummy.new d.var #=> 99 d.remove #=> 99 d.var #=> nil
Re-composes a prime factorization and returns the product.
See Prime#int_from_prime_division
for more details.
Returns a list of the private instance methods defined in mod. If the optional parameter is false
, the methods of any ancestors are not included.
module Mod def method1() end private :method1 def method2() end end Mod.instance_methods #=> [:method2] Mod.private_instance_methods #=> [:method1]
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
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>]