Explicit conversion to a Matrix
. Returns self
Return a single-column matrix from this vector
This is similar to PrettyPrint::format
but the result has no breaks.
maxwidth
, newline
and genspace
are ignored.
The invocation of breakable
in the block doesn’t break a line and is treated as just an invocation of text
.
Returns a new array with the concatenated results of running block once for every element in enum.
If no block is given, an enumerator is returned instead.
[1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4] [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100]
Returns a two element array containing the objects in enum that correspond to the minimum and maximum values respectively from the given block.
If no block is given, an enumerator is returned instead.
a = %w(albatross dog horse) a.minmax_by { |x| x.length } #=> ["dog", "albatross"]
Returns garbage collector generation for the given object
.
class B include ObjectSpace def foo trace_object_allocations do obj = Object.new p "Generation is #{allocation_generation(obj)}" end end end B.new.foo #=> "Generation is 3"
See ::trace_object_allocations
for more information and examples.
Returns the number of malloc() allocations.
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
How String
Gem paths should be split. Overridable for esoteric platforms.
Retrieves the server with the given uri
.
See also regist_server
and remove_server.
Generates the Makefile for your extension, passing along any options and preprocessor constants that you may have generated through other methods.
The target
name should correspond the name of the global function name defined within your C extension, minus the Init_
. For example, if your C extension is defined as Init_foo
, then your target would simply be “foo”.
If any “/” characters are present in the target name, only the last name is interpreted as the target name, and the rest are considered toplevel directory names, and the generated Makefile will be altered accordingly to follow that directory structure.
For example, if you pass “test/foo” as a target name, your extension will be installed under the “test” directory. This means that in order to load the file within a Ruby program later, that directory structure will have to be followed, e.g. require 'test/foo'
.
The srcprefix
should be used when your source files are not in the same directory as your build script. This will not only eliminate the need for you to manually copy the source files into the same directory as your build script, but it also sets the proper target_prefix
in the generated Makefile.
Setting the target_prefix
will, in turn, install the generated binary in a directory under your RbConfig::CONFIG['sitearchdir']
that mimics your local filesystem when you run make install
.
For example, given the following file tree:
ext/ extconf.rb test/ foo.c
And given the following code:
create_makefile('test/foo', 'test')
That will set the target_prefix
in the generated Makefile to “test”. That, in turn, will create the following file tree when installed via the make install
command:
/path/to/ruby/sitearchdir/test/foo.so
It is recommended that you use this approach to generate your makefiles, instead of copying files around manually, because some third party libraries may depend on the target_prefix
being set properly.
The srcprefix
argument can be used to override the default source directory, i.e. the current directory. It is included as part of the VPATH
and added to the list of INCFLAGS
.
Returns the contents of this Tms
object as a formatted string, according to a format
string like that passed to Kernel.format
. In addition, format
accepts the following extensions:
%u
Replaced by the user CPU time, as reported by Tms#utime
.
%y
Replaced by the system CPU time, as reported by stime
(Mnemonic: y of “s*y*stem”)
%U
Replaced by the children’s user CPU time, as reported by Tms#cutime
%Y
Replaced by the children’s system CPU time, as reported by Tms#cstime
%t
Replaced by the total CPU time, as reported by Tms#total
%r
Replaced by the elapsed real time, as reported by Tms#real
%n
Replaced by the label string, as reported by Tms#label
(Mnemonic: n of “*n*ame”)
If format
is not given, FORMAT
is used as default value, detailing the user, system and real elapsed time.
This method will fetch the field value by header
. It has the same behavior as Hash#fetch
: if there is a field with the given header
, its value is returned. Otherwise, if a block is given, it is yielded the header
and its result is returned; if a default
is given as the second argument, it is returned; otherwise a KeyError
is raised.
Sends a FETCH command to retrieve data associated with a message in the mailbox.
The set
parameter is a number or a range between two numbers, or an array of those. The number is a message sequence number, where -1 represents a ‘*’ for use in range notation like 100..-1 being interpreted as ‘100:*’. Beware that the exclude_end?
property of a Range
object is ignored, and the contents of a range are independent of the order of the range endpoints as per the protocol specification, so 1…5, 5..1 and 5…1 are all equivalent to 1..5.
attr
is a list of attributes to fetch; see the documentation for Net::IMAP::FetchData
for a list of valid attributes.
The return value is an array of Net::IMAP::FetchData
or nil (instead of an empty array) if there is no matching message.
For example:
p imap.fetch(6..8, "UID") #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\ #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\ #<Net::IMAP::FetchData seqno=8, attr={"UID"=>100}>] p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]") #=> [#<Net::IMAP::FetchData seqno=6, attr={"BODY[HEADER.FIELDS (SUBJECT)]"=>"Subject: test\r\n\r\n"}>] data = imap.uid_fetch(98, ["RFC822.SIZE", "INTERNALDATE"])[0] p data.seqno #=> 6 p data.attr["RFC822.SIZE"] #=> 611 p data.attr["INTERNALDATE"] #=> "12-Oct-2000 22:40:59 +0900" p data.attr["UID"] #=> 98
Fetches item k
from the tuple.
Fetches key
from the tuple.
Cached RemoteFetcher
instance.
Default fetcher instance. Use this instead of ::new
to reduce object allocation.
Formats arg
for the logger
If arg
is an Exception
, it will format the error message and the back trace.
If arg
responds to to_str, it will return it.
Otherwise it will return arg
.inspect.
Return value associated with key
.
If there is no value for key
and no block is given, returns ifnone
.
Otherwise, calls block passing in the given key
.
See ::DBM#fetch
for more information.
Returns the header field corresponding to the case-insensitive key. Returns the default value args
, or the result of the block, or raises an IndexError
if there’s no header field named key
See Hash#fetch