# -*- rd -*-
# $Id: features-ruby18.txt,v 1.31 2003/03/01 11:31:24 knu Exp $

= features/ruby18

Extensions for ruby 1.6 to add ruby 1.8 features.

Usage:

    # Install everything
    begin
      require 'features/ruby18'
    rescue LoadError; end

    # Install specific features only
    begin
      require 'features/ruby18/dir'
    rescue LoadError; end

    # Then use the features as you want
    Dir.chdir("foo") { puts Dir.pwd }

= features/ruby18/array

== Array(Class)

=== Class Methods

--- new(array)
--- new(size) { |i| ... }

    Constructs an array by copy and function, respectively.

=== Instance Methods

--- fetch(index)
--- fetch(index, default)
--- fetch(index) { |i| ... }

    Returns the value at <index>.  When the index is out of the array's
    extent:

    (1) If a default value is given, returns it.

    (2) If a block is given, calls it passing the index and returns the
        block's return value.

    (3) Otherwise, raises IndexError.

--- fill(index) { |i| ... }
--- fill(index, len) { |i| ... }
--- fill(range) { |i| ... }

    Accepts a block.  If a block is given, return values from the
    block is used to fill the cells with.

--- insert(pos, *values)

    Inserts the values to the array at the postion and returns self.

--- select(*indices)

    Accepts indices and returns corresponding values in an array.

--- transpose

    Transposes the rows and the column assuming that the array is an
    array of arrays.

--- zip(*arrays)
--- zip(*arrays) { |tuple| ... }

    Makes an array of tuples, each of which contains elements of given
    arrays occuring at the same position.  If a block is given, it is
    yielded for each tuple.

= features/ruby18/dir

== Dir(Class)

=== Class Methods

--- chdir(dir) { ... }

    Accepts an optional block.  When a block is given, it changes the
    current directory to <dir> and evaluates the block, then puts the
    current directory back to where it was originally.

= features/ruby18/enumerable

== Enumerable(Module)

=== Instance Methods

--- all? { |v| ... }

    Returns true if the block evaluates all the elements to true.

--- any? { |v| ... }

    Returns true if the block evaluates any of the elements to true.

--- inject { |r, v| ... }
--- inject(initial) { |r, v| ... }

    Injects the operation defined by the block between each two
    neighboring elements and returns the result.

--- partition { |v| ... }

    Partition the elements into two, one that contains all the
    elements that evaluate the given block to true, another to false.
    Equivalent to [select { |v| ... }, reject { |v| ... }].

--- sort_by { |v| ... }

    Sorts the elements by the return value from the block and returns
    a sorted array.

= features/ruby18/file

== File(Class)

=== Class Methods

--- extname(filepath)

    Returns the extension part of <filepath>, including a leading dot.
    If no relevant part is found, returns an empty string.

--- fnmatch(pattern, string, flags = 0)

    Checks the string to see if it matches the pattern according to
    the rules used by the shell.  The flags argument modifies the
    interpretation of pattern and string.  See the FNM_* constants.

--- lchmod(mode, *files)

    Similar to chmod(), but does not follow symbolic links.

--- lchown(uid, gid, *files)

    Similar to chown(), but does not follow symbolic links.

== File::Constatns(Module)

=== Constants

--- FNM_NOESCAPE
--- FNM_PATHNAME
--- FNM_CASEFOLD

    Follows POSIX.

--- FNM_DOTMATCH

    Opposite of FNM_PERIOD.

== File::Test(Class)

=== Instance Methods

--- rdev_major

    Returns the major device number.

--- rdev_minor

    Returns the minor device number.

= features/ruby18/hash

== Hash(Class)

=== Instance Methods

--- select(*keys)

    Accepts keys and returns corresponding values in an array.

--- update(hash) { |key, old_value, new_value| ... }
--- merge!(hash) { |key, old_value, new_value| ... }

    Accepts block which determines a value to adopt for each key
    conflict.  merge! is an alias for update.

--- merge(hash) { |key, old_value, new_value| ... }

    Does a merger non-destructively and returns a new hash.

= features/ruby18/io

== IO(Class)

=== Class Methods

--- for_fd(fileno, mode = "r")

    Equivalent to new(), except for_fd() doesn't complain if a block
    is given, but just ignores it.

--- read(filepath)

    Reads the entire file specified by filepath (which can be a
    command line starting with a "|") and returns the content in a
    string.

=== Instance Methods

--- fsync

    Causes all modified data and attributes of the accessing file to
    be moved to a permanent storage device.

--- read(len = nil, buf = nil)

    Accepts an optional buffer to write data to.

--- sysread(len, buf = nil)

    Accepts an optional buffer to write data to.

--- sysseek(offset, whence = IO::SEEK_SET)

    Similar to seek(), but uses a low-level seek.  Do not mix with
    other methods that read from or write to the stream or you may get
    unpredictable results.

= features/ruby18/kernel

== Kernel(Module)

=== Instance Methods

--- abort(message = nil)

    Print the message before abort if given.

= features/ruby18/marshal

== Marshal(Module)

=== Constants

--- MAJOR_VERSION

    Returns the major version number of the marshal format of the
    running ruby.

--- MIJOR_VERSION

    Returns the minor version nubmer of the marshal format of the
    running ruby.

= features/ruby18/math

== Math(Module)

=== Module Methods

--- acos(x)
--- asin(x)
--- atan(x)
--- cosh(x)
--- sinh(x)
--- tanh(x)
--- acosh(x)
--- asinh(x)
--- atanh(x)
--- hypot(x, y)

    New mathematic functions.

= features/ruby18/module

== Module(Class)

=== Instance Methods

--- include?(mod)

    Returns true if the module includes the module <mod>.

= features/ruby18/numeric

== Integer(Class)
== Fixnum(Class)
== Bignum(Class)

=== Instance Methods

--- to_s(base=10)

    Converts the integer to a string basing on <base>.  Binary (2),
    octal (8), decimal (10) and hexadecimal (16) are supported.

= features/ruby18/object

== Object(Class)

=== Instance Methods

--- object_id()

    Alias for id().

= features/ruby18/proc

== Proc(Class)

=== Instance Methods

--- yield(*args)

    Calls self but no ArgumentError will be raised like (({yield}))
    keyword.

= features/ruby18/process

== Process(Module)

=== Instance Methods

--- times

    Returns a Tms structure that contains user and system CPU times
    for the process.

= features/ruby18/range

== Range(Class)

=== Instance Methods

--- to_ary

    Returns to_a().

= features/ruby18/regexp

== Regexp(Class)

=== Instance Methods

--- hash

    Now returns the for the same value for the same expression.

--- eql?(re)

    Returns if the given object is a Regexp with the same source.

--- options

    Returns the options given when compiling the expression as an
    integer, which is a bitwise sum of Regexp::IGNORECASE,
    Regexp::EXTENDED and/or Regexp::MULTILINE.

== MatchData(Class)

=== Instance Methods

--- select(*indices)

    Returns an array of values corresponding to the indices.

--- to_ary

    Returns to_a().

= features/ruby18/string

== String(Class)

=== Class Methods

--- new()

    When no argument is given, returns an empty string. ("")

=== Instance Methods

--- [re, nth = 0]

    Performs a regexp match against the string and returns a matched
    string.  If the regexp doesn't match, returns nil.

--- [re, nth = 0] = str

    Performs a regexp match against the string and replaces the
    matched part with the given string.  If the regexp doesn't match,
    raises IndexError.

--- casecmp(other)

    Compares the string with the given string case-insensitively and
    returns an integer value like String#<=>.

--- chomp(rs = $/)
--- chomp!(rs = $/)

    If rs is equal to "\n", then any of "\r\n", "\r" and "\n" is
    chomped off.

--- insert(pos, str)

    Inserts <str> at <pos> and returns self.

--- lstrip
--- lstrip!

    Strip whitespace from the string's left side.

--- match(re)

    Invokes re.match(self).  If <re> is not a regexp, it is converted
    to a string, then to a regexp. (Regexp.new(re.to_str).match(self))

--- rstrip
--- rstrip!

    Strip whitespace from the string's right side.

--- slice(re, nth = 0)

    Performs a regexp match against the string and returns a matched
    string.  If the regexp doesn't match, returns nil.

--- slice!(re, nth = 0)

    Performs a regexp match against the string and deletes the matched
    part.  If the regexp doesn't match, raises IndexError.

--- to_i(base = 10)

    Returns to_a().

= features/ruby18/struct

== Struct::*(Class)

=== Instance Methods

--- each_pair { |member, value| ... }

     Calls block once for each instance variable, passing the member
     name and the value as parameters.

--- select(*members)

    Accepts member names and returns corresponding values in an array.

= features/ruby18/symbol

== Symbol(Class)

=== Instance Methods

--- intern

    Returns self.

= features/ruby18/thread

== Thread(Class)

=== Instance Methods

--- join(limit = nil)

    Optional argument limits maximum time to wait the thread in second.
    And returns nil if timed out.

= features/ruby18/time

== Time(Class)

=== Instance Methods

--- getgm
--- getutc

    Returns a copy of the Time object converted to UTC time.

--- getlocal

    Returns a copy of the Time object converted to local time.

= License

You may redistribute and/or modify these modules under the same
license terms as Ruby.

Copyright (C) 2002 Akinori MUSHA <knu@ruby-lang.org> and many
contributors.
