Read one byte from the tar entry
The error message for the missing dependency, including the specifications that had this dependency.
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
Passes each grapheme cluster in str to the given block, or returns an enumerator if no block is given. Unlike String#each_char
, this enumerates by grapheme clusters defined by Unicode Standard Annex #29 unicode.org/reports/tr29/
"a\u0300".each_char.to_a.size #=> 2 "a\u0300".each_grapheme_cluster.to_a.size #=> 1
Returns the Ruby source filename and line number containing first definition of constant specified. If the named constant is not found, nil
is returned. If the constant is found, but its source location can not be extracted (constant is defined in C code), empty array is returned.
inherit specifies whether to lookup in mod.ancestors
(true
by default).
# test.rb: class A C1 = 1 end module M C2 = 2 end class B < A include M C3 = 3 end class A # continuation of A definition end p B.const_source_location('C3') # => ["test.rb", 11] p B.const_source_location('C2') # => ["test.rb", 6] p B.const_source_location('C1') # => ["test.rb", 2] p B.const_source_location('C2', false) # => nil -- don't lookup in ancestors p Object.const_source_location('B') # => ["test.rb", 9] p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation" p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported p Object.const_source_location('String') # => [] -- constant is defined in C code
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
Returns true
if ios will be closed on exec.
f = open("/dev/null") f.close_on_exec? #=> false f.close_on_exec = true f.close_on_exec? #=> true f.close_on_exec = false f.close_on_exec? #=> false
Sets a close-on-exec flag.
f = open("/dev/null") f.close_on_exec = true system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory f.closed? #=> false
Ruby sets close-on-exec flags of all file descriptors by default since Ruby 2.0.0. So you don’t need to set by yourself. Also, unsetting a close-on-exec flag can cause file descriptor leak if another thread use fork() and exec() (via system() method for example). If you really needs file descriptor inheritance to child process, use spawn()‘s argument such as fd=>fd.
for compatibility
Returns true for IPv6 unique local address (fc00::/7, RFC4193). It returns false otherwise.
Returns true for IPv6 multicast node-local scope address. It returns false otherwise.
Returns true for IPv6 multicast link-local scope address. It returns false otherwise.
Returns true for IPv6 multicast site-local scope address. It returns false otherwise.
Returns true for IPv6 multicast organization-local scope address. It returns false otherwise.
Returns true for IPv6 multicast global scope address. It returns false otherwise.
Returns reference counter of Dispatch interface of WIN32OLE
object. You should not use this method because this method exists only for debugging WIN32OLE
.
Returns the array of WIN32OLE_METHOD
object . The element of the array is property (gettable) of WIN32OLE
object.
excel = WIN32OLE.new('Excel.Application') properties = excel.ole_get_methods
Handle BasicObject
instances
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'")