Returns true
if rat
is greater than 0.
Returns true
if rat
is less than 0.
Returns true if the set contains no elements.
Equivalent to Set#delete_if
, but returns nil if no changes were made. Returns an enumerator if no block is given.
Replaces the contents of the set with the contents of the given enumerable object and returns self.
set = Set[1, 'c', :s] #=> #<Set: {1, "c", :s}> set.replace([1, 2]) #=> #<Set: {1, 2}> set #=> #<Set: {1, 2}>
Resets the internal state after modification to existing elements and returns self. Elements will be reindexed and deduplicated.
Returns a new set built by duplicating the set, removing every element that appears in the given enumerable object.
Set[1, 3, 5] - Set[1, 5] #=> #<Set: {3}> Set['a', 'b', 'z'] - ['a', 'c'] #=> #<Set: {"b", "z"}>
Returns true if the set contains the given object:
Set[1, 2, 3].include? 2 #=> true Set[1, 2, 3].include? 4 #=> false
Note that include?
and member?
do not test member equality using ==
as do other Enumerables.
This is aliased to ===
, so it is usable in case
expressions:
case :apple when Set[:potato, :carrot] "vegetable" when Set[:apple, :banana] "fruit" end # => "fruit"
See also Enumerable#include?
Returns the member names of the Struct
descendant as an array:
Customer = Struct.new(:name, :address, :zip) Customer.members # => [:name, :address, :zip]
Returns the member names from self
as an array:
Customer = Struct.new(:name, :address, :zip) Customer.new.members # => [:name, :address, :zip]
Related: to_a
.
Returns true
if self
is :''
, false
otherwise.
Returns true
if self
points to a mountpoint.
Returns the children of the directory (files and subdirectories, not recursive) as an array of Pathname
objects.
By default, the returned pathnames will have enough information to access the files. If you set with_directory
to false
, then the returned pathnames will contain the filename only.
For example:
pn = Pathname("/usr/lib/ruby/1.8") pn.children # -> [ Pathname:/usr/lib/ruby/1.8/English.rb, Pathname:/usr/lib/ruby/1.8/Env.rb, Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ] pn.children(false) # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
Note that the results never contain the entries .
and ..
in the directory because they are not children.
Recursively deletes a directory, including all directories beneath it.
See FileUtils.rm_rf
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.
Returns all the bytes from the file, or the first N
if specified.
See File.binread
.