catch
executes its block. If throw
is not called, the block executes normally, and catch
returns the value of the last expression evaluated.
catch(1) { 123 } # => 123
If throw(tag2, val)
is called, Ruby searches up its stack for a catch
block whose tag
has the same object_id
as tag2. When found, the block stops executing and returns val (or nil
if no second argument was given to throw
).
catch(1) { throw(1, 456) } # => 456 catch(1) { throw(1) } # => nil
When tag
is passed as the first argument, catch
yields it as the parameter of the block.
catch(1) {|x| x + 2 } # => 3
When no tag
is given, catch
yields a new unique object (as from Object.new
) as the block parameter. This object can then be used as the argument to throw
, and will match the correct catch
block.
catch do |obj_A| catch do |obj_B| throw(obj_B, 123) puts "This puts is not reached" end puts "This puts is displayed" 456 end # => 456 catch do |obj_A| catch do |obj_B| throw(obj_A, 123) puts "This puts is still not reached" end puts "Now this puts is also not reached" 456 end # => 123
Matches addr
against this entry.
Matches addr
against each ACLEntry
in this list.
Completion
for hash key.
Matches this template against tuple
. The tuple
must be the same size as the template. An element with a nil
value in a template acts as a wildcard, matching any value in the corresponding position in the tuple. Elements of the template match the tuple
if the are ==
or ===
.
Template.new([:foo, 5]).match Tuple.new([:foo, 5]) # => true Template.new([:foo, nil]).match Tuple.new([:foo, 5]) # => true Template.new([String]).match Tuple.new(['hello']) # => true Template.new([:foo]).match Tuple.new([:foo, 5]) # => false Template.new([:foo, 6]).match Tuple.new([:foo, 5]) # => false Template.new([:foo, nil]).match Tuple.new([:foo]) # => false Template.new([:foo, 6]).match Tuple.new([:foo]) # => false
Matches this TemplateEntry
against tuple
. See Template#match
for details on how a Template
matches a Tuple
.
Does this dependency match the specification described by name
and version
or match spec
?
NOTE: Unlike matches_spec?
this method does not return true when the version is a prerelease version unless this is a prerelease dependency.
Indicate if this NameTuple
matches the current platform.
Set
date-time format.
datetime_format
A string suitable for passing to strftime
.
Returns the date format being used. See datetime_format=
Creates an OptionParser::Switch
from the parameters. The parsed argument value is passed to the given block, where it can be processed.
See at the beginning of OptionParser
for some full examples.
params
can include the following elements:
One of the following:
:NONE, :REQUIRED, :OPTIONAL
Acceptable option argument format, must be pre-defined with OptionParser.accept
or OptionParser#accept
, or Regexp
. This can appear once or assigned as String
if not present, otherwise causes an ArgumentError
. Examples:
Float, Time, Array
[:text, :binary, :auto] %w[iso-2022-jp shift_jis euc-jp utf8 binary] { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
Specifies a long style switch which takes a mandatory, optional or no argument. It’s a string of the following form:
"--switch=MANDATORY" or "--switch MANDATORY" "--switch[=OPTIONAL]" "--switch"
Specifies short style switch which takes a mandatory, optional or no argument. It’s a string of the following form:
"-xMANDATORY" "-x[OPTIONAL]" "-x"
There is also a special form which matches character range (not full set of regular expression):
"-[a-z]MANDATORY" "-[a-z][OPTIONAL]" "-[a-z]"
Instead of specifying mandatory or optional arguments directly in the switch parameter, this separate parameter can be used.
"=MANDATORY" "=[OPTIONAL]"
Description string for the option.
"Run verbosely"
If you give multiple description strings, each string will be printed line by line.
Handler for the parsed argument value. Either give a block or pass a Proc
or Method
as an argument.
Does this dependency match spec
?
NOTE: This is not a convenience method. Unlike match?
this method returns true when spec
is a prerelease version even if this dependency is not a prerelease dependency.
Sends a PATCH request to the path
and gets a response, as an HTTPResponse
object.
Sends a PROPPATCH request to the path
and gets a response, as an HTTPResponse
object.