Results for: "OptionParser"

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 objects to the set and returns self.

No documentation available

Resets the internal state after modification to existing elements and returns self.

Elements will be reindexed and deduplicated.

With a block given, returns an array of values from self for which the block returns a truthy value:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
a = joe.select {|value| value.is_a?(String) }
a # => ["Joe Smith", "123 Maple, Anytown NC"]
a = joe.select {|value| value.is_a?(Integer) }
a # => [12345]

With no block given, returns an Enumerator.

With a block given, returns an array of values from self for which the block returns a truthy value:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
a = joe.select {|value| value.is_a?(String) }
a # => ["Joe Smith", "123 Maple, Anytown NC"]
a = joe.select {|value| value.is_a?(Integer) }
a # => [12345]

With no block given, returns an Enumerator.

Returns the values in self as an array:

Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.to_a # => ["Joe Smith", "123 Maple, Anytown NC", 12345]

Related: members.

Like Symbol#<=>, but case-insensitive; equivalent to self.to_s.casecmp(object.to_s):

lower = :abc
upper = :ABC
upper.casecmp(lower) # => 0
lower.casecmp(lower) # => 0
lower.casecmp(upper) # => 0

Returns nil if self and object have incompatible encodings, or if object is not a symbol:

sym = 'äöü'.encode("ISO-8859-1").to_sym
other_sym = 'ÄÖÜ'
sym.casecmp(other_sym) # => nil
:foo.casecmp(2)        # => nil

Unlike Symbol#casecmp?, case-insensitivity does not work for characters outside of ‘A’..‘Z’ and ‘a’..‘z’:

lower = :äöü
upper = :ÄÖÜ
upper.casecmp(lower) # => -1
lower.casecmp(lower) # => 0
lower.casecmp(upper) # => 1

Related: Symbol#casecmp?, String#casecmp.

Returns true if self and object are equal after Unicode case folding, otherwise false:

lower = :abc
upper = :ABC
upper.casecmp?(lower) # => true
lower.casecmp?(lower) # => true
lower.casecmp?(upper) # => true

Returns nil if self and object have incompatible encodings, or if object is not a symbol:

sym = 'äöü'.encode("ISO-8859-1").to_sym
other_sym = 'ÄÖÜ'
sym.casecmp?(other_sym) # => nil
:foo.casecmp?(2)        # => nil

Unlike Symbol#casecmp, works for characters outside of ‘A’..‘Z’ and ‘a’..‘z’:

lower = :äöü
upper = :ÄÖÜ
upper.casecmp?(lower) # => true
lower.casecmp?(lower) # => true
lower.casecmp?(upper) # => true

Related: Symbol#casecmp, String#casecmp?.

Returns true if self is :'', false otherwise.

Equivalent to sym.to_s.upcase.to_sym.

See String#upcase.

Equivalent to sym.to_s.downcase.to_sym.

See String#downcase.

Related: Symbol#upcase.

Equivalent to sym.to_s.swapcase.to_sym.

See String#swapcase.

No documentation available

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        #=> []

Anonymous subclasses (not associated with a constant) are returned, too:

c = Class.new(A)
A.subclasses        # => [#<Class:0x00007f003c77bd78>, D, B]

Note that the parent does not hold references to subclasses and doesn’t prevent them from being garbage collected. This means that the subclass might disappear when all references to it are dropped:

# drop the reference to subclass, it can be garbage-collected now
c = nil

A.subclasses
# It can be
#  => [#<Class:0x00007f003c77bd78>, D, B]
# ...or just
#  => [D, B]
# ...depending on whether garbage collector was run

Enters exclusive section.

Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin.

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.

Search took: 7ms  ·  Total Results: 6041