Create a new UnlessNode
node
in foo | bar
Returns a 2-length array; the first item is the result of BigDecimal#precision
and the second one is of BigDecimal#scale
.
See BigDecimal#precision
. See BigDecimal#scale
.
Initializes the MonitorMixin
after being included in a class or when an object has been extended with the MonitorMixin
Returns a string containing the RFC-2045-compliant Base64-encoding of bin
.
Per RFC 2045, the returned string may contain the URL-unsafe characters +
or /
; see Encoding Character Set above:
Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n" Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
The returned string may include padding; see Padding above.
Base64.strict_encode64('*') # => "Kg==\n"
The returned string will have no newline characters, regardless of its length; see Newlines above:
Base64.strict_encode64('*') # => "Kg==" Base64.strict_encode64('*' * 46) # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
The string to be encoded may itself contain newlines, which will be encoded as ordinary Base64:
Base64.strict_encode64("\n\n\n") # => "CgoK" s = "This is line 1\nThis is line 2\n" Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
Returns the convertible integer type of the given type
. You may optionally specify additional headers
to search in for the type
. convertible means actually the same type, or typedef’d from the same type.
If the type
is an integer type and the convertible type is found, the following macros are passed as preprocessor constants to the compiler using the type
name, in uppercase.
TYPEOF_
, followed by the type
name, followed by =X
where “X” is the found convertible type name.
TYP2NUM
and NUM2TYP
, where TYP
is the type
name in uppercase with replacing an _t
suffix with “T”, followed by =X
where “X” is the macro name to convert type
to an Integer
object, and vice versa.
For example, if foobar_t
is defined as unsigned long, then convertible_int("foobar_t")
would return “unsigned long”, and define these macros:
#define TYPEOF_FOOBAR_T unsigned long #define FOOBART2NUM ULONG2NUM #define NUM2FOOBART NUM2ULONG
Returns an array of the names of singleton methods for obj. If the optional all parameter is true, the list will include methods in modules included in obj. Only public and protected singleton methods are returned.
module Other def three() end end class Single def Single.four() end end a = Single.new def a.one() end class << a include Other def two() end end Single.singleton_methods #=> [:four] a.singleton_methods(false) #=> [:two, :one] a.singleton_methods #=> [:two, :one, :three]
Similar to method, searches singleton method only.
class Demo def initialize(n) @iv = n end def hello() "Hello, @iv = #{@iv}" end end k = Demo.new(99) def k.hi "Hi, @iv = #{@iv}" end m = k.singleton_method(:hi) m.call #=> "Hi, @iv = 99" m = k.singleton_method(:hello) #=> NameError
Returns an array of the string method names of the methods that accept the given keyword option opt
; the argument must be a symbol:
FileUtils.collect_method(:preserve) # => ["cp", "copy", "cp_r", "install"]
Sets the encoding to be used for the response body; returns the encoding.
The given value
may be:
An Encoding
object.
The name of an encoding.
An alias for an encoding name.
See Encoding
.
Examples:
http = Net::HTTP.new(hostname) http.response_body_encoding = Encoding::US_ASCII # => #<Encoding:US-ASCII> http.response_body_encoding = 'US-ASCII' # => "US-ASCII" http.response_body_encoding = 'ASCII' # => "ASCII"
Initialize WIN32OLE
object(ActiveX Control) by calling IPersistMemory::InitNew.
Before calling OLE method, some kind of the ActiveX controls created with MFC should be initialized by calling IPersistXXX::InitNew.
If and only if you received the exception “HRESULT error code: 0x8000ffff catastrophic failure”, try this method before invoking any ole_method.
obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control") obj.ole_activex_initialize obj.method(...)
Yields each frame of the current execution stack as a backtrace location object.
Returns the method identifier for the given object
.
class A include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}" end end end A.new.foo #=> "Class#new"
See ::trace_object_allocations
for more information and examples.
The file name and line number of the caller of the caller of this method.
depth
is how many layers up the call stack it should go.
e.g.,
def a; Gem.location_of_caller
; end a #=> [“x.rb”, 2] # (it’ll vary depending on file name and line number)
def b; c; end def c; Gem.location_of_caller(2)
; end b #=> [“x.rb”, 6] # (it’ll vary depending on file name and line number)
Path to specification files of default gems.
Returns a new lazy enumerator with the concatenated results of running block
once for every element in the lazy enumerator.
["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force #=> ["f", "o", "o", "b", "a", "r"]
A value x
returned by block
is decomposed if either of the following conditions is true:
x
responds to both each and force, which means that x
is a lazy enumerator.
x
is an array or responds to to_ary.
Otherwise, x
is contained as-is in the return value.
[{a:1}, {b:2}].lazy.flat_map {|i| i}.force #=> [{:a=>1}, {:b=>2}]
Returns a hash of default options used by the Ruby iseq compiler.
For details, see InstructionSequence.compile_option=
.
Sets the default values for various optimizations in the Ruby iseq compiler.
Possible values for options
include true
, which enables all options, false
which disables all options, and nil
which leaves all options unchanged.
You can also pass a Hash
of options
that you want to change, any options not present in the hash will be left unchanged.
Possible option names (which are keys in options
) which can be set to true
or false
include:
:inline_const_cache
:instructions_unification
:operands_unification
:peephole_optimization
:specialized_instruction
:tailcall_optimization
Additionally, :debug_level
can be set to an integer.
These default options can be overwritten for a single run of the iseq compiler by passing any of the above values as the options
parameter to ::new
, ::compile
and ::compile_file
.
Remove previously defined command-line argument name
.
Handle the given list of arguments by parsing them and recording the results.