Returns a nicely-formatted string representation of self
:
/ab+c/ix.inspect # => "/ab+c/ix"
Related: Regexp#to_s
.
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 enumerable 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 Set[1, 2, 3].intersect? 4..5 #=> false Set[1, 2, 3].intersect? [3, 4] #=> true
Returns true if the set and the given enumerable 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 Set[1, 2, 3].disjoint? [3, 4] #=> false Set[1, 2, 3].disjoint? 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, …}>”).
Returns a string representation of self
:
Customer = Struct.new(:name, :address, :zip) # => Customer joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.inspect # => "#<struct Customer name=\"Joe Smith\", address=\"123 Maple, Anytown NC\", zip=12345>"
Returns a string representation of self
(including the leading colon):
:foo.inspect # => ":foo"
Related: Symbol#to_s
, Symbol#name
.
Equivalent to self.to_s.match
, including possible updates to global variables; see String#match
.
Equivalent to sym.to_s.match?
; see String#match
.
Equivalent to self.to_s.encoding
; see String#encoding
.
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. This is effectively the same as using Pathname#+
to append self
and all arguments sequentially.
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 all the bytes from the file, or the first N
if specified.
See File.binread
.
Removes a file or directory, using File.unlink
if self
is a file, or Dir.unlink
as necessary.