Returns a string containing a detailed summary of the keys and values.
Convert this range object to a printable form (using inspect
to convert the begin and end objects).
Returns true
if obj
is an element of the range, false
otherwise.
("a".."z").include?("g") #=> true ("a".."z").include?("A") #=> false ("a".."z").include?("cc") #=> false
If you need to ensure obj
is between begin
and end
, use cover?
("a".."z").cover?("cc") #=> true
If begin and end are numeric, include?
behaves like cover?
(1..3).include?(1.5) # => true
Returns a MatchData
object describing the match, or nil
if there was no match. This is equivalent to retrieving the value of the special variable $~
following a normal match. If the second parameter is present, it specifies the position in the string to begin the search.
/(.)(.)(.)/.match("abc")[2] #=> "b" /(.)(.)/.match("abc", 1)[2] #=> "c"
If a block is given, invoke the block with MatchData
if match succeed, so that you can write
/M(.*)/.match("Matz") do |m| puts m[0] puts m[1] end
instead of
if m = /M(.*)/.match("Matz") puts m[0] puts m[1] end
The return value is a value from block execution in this case.
Returns a true
or false
indicates whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search.
/R.../.match?("Ruby") #=> true /R.../.match?("Ruby", 1) #=> false /P.../.match?("Ruby") #=> false $& #=> nil
Produce a nicely formatted string-version of rxp. Perhaps surprisingly, #inspect
actually produces the more natural version of the string than #to_s
.
/ab+c/ix.inspect #=> "/ab+c/ix"
Returns the Encoding
object that represents the encoding of obj.
Returns true if the set contains the given object.
Note that include?
and member?
do not test member equality using ==
as do other Enumerables.
See also Enumerable#include?
Returns true if the set and the given set have at least one element in common.
Set[1, 2, 3].intersect? Set[4, 5] #=> false Set[1, 2, 3].intersect? Set[3, 4] #=> true
Returns true if the set and the given set have no element in common. This method is the opposite of intersect?
.
Set[1, 2, 3].disjoint? Set[3, 4] #=> false Set[1, 2, 3].disjoint? Set[4, 5] #=> true
Returns a string created by converting each element of the set to a string See also: Array#join
Returns a string containing a human-readable representation of the set (“#<Set: {element1, element2, …}>”).
In general, to_sym
returns the Symbol
corresponding to an object. As sym is already a symbol, self
is returned in this case.
Returns sym.to_s.match
.
Returns sym.to_s.match?
.
Returns the Encoding
object that represents the encoding of sym.
Callback invoked whenever a subclass of the current class is created.
Example:
class Foo def self.inherited(subclass) puts "New subclass: #{subclass}" end end class Bar < Foo end class Baz < Bar end
produces:
New subclass: Bar New subclass: Baz
Returns true
if self
points to a mountpoint.
Joins the given pathnames onto self
to create a new Pathname
object.
path0 = Pathname.new("/usr") # Pathname:/usr path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby # is the same as path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby path0 == path1 #=> true
Iterates over the directory tree in a depth first manner, yielding a Pathname
for each file under “this” directory.
Returns an Enumerator
if no block is given.
Since it is implemented by the standard library module Find
, Find.prune
can be used to control the traversal.
If self
is .
, yielded pathnames begin with a filename in the current directory, not ./
.
See Find.find
Returns pathname. This method is deprecated and will be removed in Ruby 3.2.