Visit the targets of a multi-target node.
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 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}]
Like Enumerable#take_while
, but chains operation to be lazy-evaluated.
Like Enumerable#take
, but chains operation to be lazy-evaluated.
Generates a random prime number of bit length bits. If safe is set to true
, generates a safe prime. If add is specified, generates a prime that fulfills condition p % add = rem
.
Sets the authentication tag to verify the integrity of the ciphertext. This can be called only when the cipher supports AE. The tag must be set after calling Cipher#decrypt
, Cipher#key=
and Cipher#iv=
, but before calling Cipher#final
. After all decryption is performed, the tag is verified automatically in the call to Cipher#final
.
For OCB mode, the tag length must be supplied with auth_tag_len=
beforehand.
Gets the authentication tag generated by Authenticated Encryption Cipher
modes (GCM for example). This tag may be stored along with the ciphertext, then set on the decryption cipher to authenticate the contents of the ciphertext against changes. If the optional integer parameter tag_len is given, the returned tag will be tag_len bytes long. If the parameter is omitted, the default length of 16 bytes or the length previously set by auth_tag_len=
will be used. For maximum security, the longest possible should be chosen.
The tag may only be retrieved after calling Cipher#final
.
Called with encoding
when the YAML
stream starts. This method is called once per stream. A stream may contain multiple documents.
See the constants in Psych::Parser
for the possible values of encoding
.
Called when the document starts with the declared version
, tag_directives
, if the document is implicit
.
version
will be an array of integers indicating the YAML
version being dealt with, tag_directives
is a list of tuples indicating the prefix and suffix of each tag, and implicit
is a boolean indicating whether the document is started implicitly.
Given the following YAML:
%YAML 1.1 %TAG ! tag:tenderlovemaking.com,2009: --- !squee
The parameters for start_document
must be this:
version # => [1, 1] tag_directives # => [["!", "tag:tenderlovemaking.com,2009:"]] implicit # => false
Called when a sequence is started.
anchor
is the anchor associated with the sequence or nil. tag
is the tag associated with the sequence or nil. implicit
a boolean indicating whether or not the sequence was implicitly started. style
is an integer indicating the list style.
See the constants in Psych::Nodes::Sequence
for the possible values of style
.
Here is a YAML
document that exercises most of the possible ways this method can be called:
--- - !!seq [ a ] - &pewpew - b
The above YAML
document consists of three lists, an outer list that contains two inner lists. Here is a matrix of the parameters sent to represent these lists:
# anchor tag implicit style [nil, nil, true, 1 ] [nil, "tag:yaml.org,2002:seq", false, 2 ] ["pewpew", nil, true, 1 ]
Called when a map starts.
anchor
is the anchor associated with the map or nil
. tag
is the tag associated with the map or nil
. implicit
is a boolean indicating whether or not the map was implicitly started. style
is an integer indicating the mapping style.
See the constants in Psych::Nodes::Mapping
for the possible values of style
.
Here is a YAML
document that exercises most of the possible ways this method can be called:
--- k: !!map { hello: world } v: &pewpew hello: world
The above YAML
document consists of three maps, an outer map that contains two inner maps. Below is a matrix of the parameters sent in order to represent these three maps:
# anchor tag implicit style [nil, nil, true, 1 ] [nil, "tag:yaml.org,2002:map", false, 2 ] ["pewpew", nil, true, 1 ]
Called before each event with line/column information.
Handles start_document
events with version
, tag_directives
, and implicit
styling.
Start a document emission with YAML
version
, tags
, and an implicit
start.
Start emitting a sequence with anchor
, a tag
, implicit
sequence start and end, along with style
.
Start emitting a YAML
map with anchor
, tag
, an implicit
start and end, and style
.