Downloads uri
and returns it as a String.
A recommended version for use with a ~> Requirement.
Does this dependency request match spec
?
NOTE: matches_spec?
matches prerelease versions. See also match?
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
Formats params
according to format_string
which is described in setup_params.
Switch the effective and real user IDs of the current process. If a block is given, the user IDs will be switched back after the block is executed. Returns the new effective user ID if called without a block, and the return value of the block if one is given.
Switch the effective and real group IDs of the current process. If a block is given, the group IDs will be switched back after the block is executed. Returns the new effective group ID if called without a block, and the return value of the block if one is given.
When invoked with a block, yield all repeated permutations of length n
of the elements of the array, then return the array itself.
The implementation makes no guarantees about the order in which the repeated permutations are yielded.
If no block is given, an Enumerator
is returned instead.
Examples:
a = [1, 2] a.repeated_permutation(1).to_a #=> [[1], [2]] a.repeated_permutation(2).to_a #=> [[1,1],[1,2],[2,1],[2,2]] a.repeated_permutation(3).to_a #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2], # [2,1,1],[2,1,2],[2,2,1],[2,2,2]] a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0
When invoked with a block, yields all repeated combinations of length n
of elements from the array and then returns the array itself.
The implementation makes no guarantees about the order in which the repeated combinations are yielded.
If no block is given, an Enumerator
is returned instead.
Examples:
a = [1, 2, 3] a.repeated_combination(1).to_a #=> [[1], [2], [3]] a.repeated_combination(2).to_a #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]] a.repeated_combination(3).to_a #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3], # [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]] a.repeated_combination(4).to_a #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3], # [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3], # [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]] a.repeated_combination(0).to_a #=> [[]] # one combination of length 0
Passes each character in str to the given block, or returns an enumerator if no block is given.
"hello".each_char {|c| print c, ' ' }
produces:
h e l l o