Removes all elements and returns self.
set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}> set.clear #=> #<Set: {}> set #=> #<Set: {}>
Returns true if the set is a subset of the given set.
Equivalent to Set#keep_if
, but returns nil if no changes were made. Returns an enumerator if no block is given.
Equivalent to Set#select!
Merges the elements of the given enumerable object to the set and returns self.
Resets the internal state after modification to existing elements and returns self.
Elements will be reindexed and deduplicated.
In general, to_sym
returns the Symbol
corresponding to an object. As sym is already a symbol, self
is returned in this case.
Case-insensitive version of Symbol#<=>:
:aBcDeF.casecmp(:abcde) # => 1 :aBcDeF.casecmp(:abcdef) # => 0 :aBcDeF.casecmp(:abcdefg) # => -1 :abcdef.casecmp(:ABCDEF) # => 0
Returns nil
if the two symbols have incompatible encodings, or if other_symbol
is not a symbol:
sym = "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym other_sym = :"\u{c4 d6 dc}" sym.casecmp(other_sym) # => nil :foo.casecmp(2) # => nil
Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from Symbol#casecmp?
.
Related: Symbol#casecmp?
.
Returns true
if sym
and other_symbol
are equal after Unicode case folding, false
if they are not equal:
:aBcDeF.casecmp?(:abcde) # => false :aBcDeF.casecmp?(:abcdef) # => true :aBcDeF.casecmp?(:abcdefg) # => false :abcdef.casecmp?(:ABCDEF) # => true :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") #=> true
Returns nil
if the two symbols have incompatible encodings, or if other_symbol
is not a symbol:
sym = "\u{e4 f6 fc}".encode("ISO-8859-1").to_sym other_sym = :"\u{c4 d6 dc}" sym.casecmp?(other_sym) # => nil :foo.casecmp?(2) # => nil
See Case Mapping.
Related: Symbol#casecmp
.
Returns whether sym is :“” or not.
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 the superclass of class, or nil
.
File.superclass #=> IO IO.superclass #=> Object Object.superclass #=> BasicObject class Foo; end class Bar < Foo; end Bar.superclass #=> Foo
Returns nil when the given class does not have a parent class:
BasicObject.superclass #=> nil
Returns an array of classes where the receiver is the direct superclass of the class, excluding singleton classes. The order of the returned array is not defined.
class A; end class B < A; end class C < B; end class D < A; end A.subclasses #=> [D, B] B.subclasses #=> [C] C.subclasses #=> []
The opposite of Pathname#absolute?
It returns false
if the pathname begins with a slash.
p = Pathname.new('/im/sure') p.relative? #=> false p = Pathname.new('not/so/sure') p.relative? #=> true
Creates a full path, including any intermediate directories that don’t yet exist.
See FileUtils.mkpath
and FileUtils.mkdir_p
Returns the real (absolute) pathname for self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
All components of the pathname must exist when this method is called.
Returns the real (absolute) pathname of self
in the actual filesystem.
Does not contain symlinks or useless dots, ..
and .
.
The last component of the real pathname can be nonexistent.