Results for: "OptionParser"

Returns true if the underlying file descriptor of ios will be closed automatically at its finalization, otherwise false.

Sets auto-close flag.

f = open("/dev/null")
IO.for_fd(f.fileno)
# ...
f.gets # may cause IOError

f = open("/dev/null")
IO.for_fd(f.fileno).autoclose = true
# ...
f.gets # won't cause IOError

If called without a block, this is synonymous to GDBM::new. If a block is given, the new GDBM instance will be passed to the block as a parameter, and the corresponding database file will be closed after the execution of the block code has been finished.

Example for an open call with a block:

require 'gdbm'
GDBM.open("fruitstore.db") do |gdbm|
  gdbm.each_pair do |key, value|
    print "#{key}: #{value}\n"
  end
end

Closes the associated database file.

Returns true if the associated database file has been closed.

Returns a new array of all key-value pairs of the database for which block evaluates to true.

Returns true if the database is empty.

Removes all the key-value pairs within gdbm.

Returns a hash created by using gdbm’s values as keys, and the keys as values.

Returns true if the given key k exists within the database. Returns false otherwise.

Returns the first object in the range, or an array of the first n elements.

(10..20).first     #=> 10
(10..20).first(3)  #=> [10, 11, 12]

Returns true if obj is an element of the range, false otherwise. If begin and end are numeric, comparison is done according to the magnitude of the values.

("a".."z").include?("g")   #=> true
("a".."z").include?("A")   #=> false
("a".."z").include?("cc")  #=> false

Returns true if obj is between the begin and end of the range.

This tests begin <= obj <= end when exclude_end? is false and begin <= obj < end when exclude_end? is true.

("a".."z").cover?("c")    #=> true
("a".."z").cover?("5")    #=> false
("a".."z").cover?("cc")   #=> true

Returns the value of the case-insensitive flag.

/a/.casefold?           #=> false
/a/i.casefold?          #=> true
/(?i:a)/.casefold?      #=> false

provides a unified clone operation, for REXML::XPathParser to use across multiple Object types

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#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from Symbol#casecmp?.

:aBcDeF.casecmp(:abcde)     #=> 1
:aBcDeF.casecmp(:abcdef)    #=> 0
:aBcDeF.casecmp(:abcdefg)   #=> -1
:abcdef.casecmp(:ABCDEF)    #=> 0

nil is returned if the two symbols have incompatible encodings, or if other_symbol is not a symbol.

:foo.casecmp(2)   #=> nil
"\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}")   #=> nil

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

nil is returned if the two symbols have incompatible encodings, or if other_symbol is not a symbol.

:foo.casecmp?(2)   #=> nil
"\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp?(:"\u{c4 d6 dc}")   #=> nil

Returns whether sym is :“” or not.

Same as sym.to_s.upcase.intern.

Same as sym.to_s.downcase.intern.

Same as sym.to_s.swapcase.intern.

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

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
Search took: 6ms  ·  Total Results: 4252