Returns the Base64-encoded version of bin
. This method complies with RFC 4648. No line feeds are added.
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
Initializes the MonitorMixin
after being included in a class or when an object has been extended with the MonitorMixin
| RelationalExpr
(‘<’ | ‘>’ | ‘<=’ | ‘>=’) AdditiveExpr
| AdditiveExpr
Invoked as a callback whenever a singleton method is removed from the receiver.
module Chatty def Chatty.singleton_method_removed(id) puts "Removing #{id.id2name}" end def self.one() end def two() end def Chatty.three() end class << self remove_method :three remove_method :one end end
produces:
Removing three Removing one
Returns a new lazy enumerator with the concatenated results of running block once for every element in lazy.
["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:
a) <i>x</i> responds to both each and force, which means that <i>x</i> is a lazy enumerator. b) <i>x</i> 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
:stack_caching
: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.
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(...)
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.
Sets whether or not to ignore case on completion.
Returns true if completion ignores case. If no, returns false.
NOTE: Returns the same object that is specified by Readline.completion_case_fold=
method.
require "readline" Readline.completion_case_fold = "This is a String." p Readline.completion_case_fold # => "This is a String."
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)
Invokes the given block once for each element of self
.
Creates a new array containing the values returned by the block.
See also Enumerable#collect
.
If no block is given, an Enumerator
is returned instead.
a = [ "a", "b", "c", "d" ] a.collect {|x| x + "!"} #=> ["a!", "b!", "c!", "d!"] a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"] a #=> ["a", "b", "c", "d"]
Invokes the given block once for each element of self
, replacing the element with the value returned by the block.
See also Enumerable#collect
.
If no block is given, an Enumerator
is returned instead.
a = [ "a", "b", "c", "d" ] a.map! {|x| x + "!" } a #=> [ "a!", "b!", "c!", "d!" ] a.collect!.with_index {|x, i| x[0...i] } a #=> ["", "b", "c!", "d!"]
Returns a new array containing all elements of ary
for which the given block
returns a true value.
If no block is given, an Enumerator
is returned instead.
[1,2,3,4,5].select {|num| num.even? } #=> [2, 4] a = %w[ a b c d e f ] a.select {|v| v =~ /[aeiou]/ } #=> ["a", "e"]
See also Enumerable#select
.
Array#filter
is an alias for Array#select
.
Invokes the given block passing in successive elements from self
, deleting elements for which the block returns a false
value.
The array may not be changed instantly every time the block is called.
If changes were made, it will return self
, otherwise it returns nil
.
If no block is given, an Enumerator
is returned instead.
See also Array#keep_if
.
Array#filter!
is an alias for Array#select!
.
Returns a complex object which denotes the given rectangular form.
Complex.rectangular(1, 2) #=> (1+2i)
Returns an array; [num, 0].
Produces unescaped version of str
. See also String#dump
because String#undump
does inverse of String#dump
.
"\"hello \\n ''\"".undump #=> "hello \n ''"