File indexing completed on 2024-04-21 04:35:50

0001 ##
0002 # Ruby Version: 2.1.0
0003 # This file is generated, all changes made in this file will be lost!
0004 
0005 
0006 ##
0007 # The marshaling library converts collections of Ruby objects into a
0008 # byte stream, allowing them to be stored outside the currently
0009 # active script. This data may subsequently be read and the original
0010 # objects reconstituted.
0011 # 
0012 # Marshaled data has major and minor version numbers stored along
0013 # with the object information. In normal use, marshaling can only
0014 # load data written with the same major version number and an equal
0015 # or lower minor version number. If Ruby's ``verbose'' flag is set
0016 # (normally using -d, -v, -w, or --verbose) the major and minor
0017 # numbers must match exactly. Marshal versioning is independent of
0018 # Ruby's version numbers. You can extract the version by reading the
0019 # first two bytes of marshaled data.
0020 # 
0021 #     str = Marshal.dump("thing")
0022 #     RUBY_VERSION   #=> "1.9.0"
0023 #     str[0].ord     #=> 4
0024 #     str[1].ord     #=> 8
0025 # 
0026 # Some objects cannot be dumped: if the objects to be dumped include
0027 # bindings, procedure or method objects, instances of class IO, or
0028 # singleton objects, a TypeError will be raised.
0029 # 
0030 # If your class has special serialization needs (for example, if you
0031 # want to serialize in some specific format), or if it contains
0032 # objects that would otherwise not be serializable, you can implement
0033 # your own serialization strategy.
0034 # 
0035 # There are two methods of doing this, your object can define either
0036 # marshal_dump and marshal_load or _dump and _load.  marshal_dump will take
0037 # precedence over _dump if both are defined.  marshal_dump may result in
0038 # smaller Marshal strings.
0039 # 
0040 # == Security considerations
0041 # 
0042 # By design, Marshal.load can deserialize almost any class loaded into the
0043 # Ruby process. In many cases this can lead to remote code execution if the
0044 # Marshal data is loaded from an untrusted source.
0045 # 
0046 # As a result, Marshal.load is not suitable as a general purpose serialization
0047 # format and you should never unmarshal user supplied input or other untrusted
0048 # data.
0049 # 
0050 # If you need to deserialize untrusted data, use JSON or another serialization
0051 # format that is only able to load simple, 'primitive' types such as String,
0052 # Array, Hash, etc. Never allow user input to specify arbitrary types to
0053 # deserialize into.
0054 # 
0055 # == marshal_dump and marshal_load
0056 # 
0057 # When dumping an object the method marshal_dump will be called.
0058 # marshal_dump must return a result containing the information necessary for
0059 # marshal_load to reconstitute the object.  The result can be any object.
0060 # 
0061 # When loading an object dumped using marshal_dump the object is first
0062 # allocated then marshal_load is called with the result from marshal_dump.
0063 # marshal_load must recreate the object from the information in the result.
0064 # 
0065 # Example:
0066 # 
0067 #   class MyObj
0068 #     def initialize name, version, data
0069 #       @name    = name
0070 #       @version = version
0071 #       @data    = data
0072 #     end
0073 # 
0074 #     def marshal_dump
0075 #       [@name, @version]
0076 #     end
0077 # 
0078 #     def marshal_load array
0079 #       @name, @version = array
0080 #     end
0081 #   end
0082 # 
0083 # == _dump and _load
0084 # 
0085 # Use _dump and _load when you need to allocate the object you're restoring
0086 # yourself.
0087 # 
0088 # When dumping an object the instance method _dump is called with an Integer
0089 # which indicates the maximum depth of objects to dump (a value of -1 implies
0090 # that you should disable depth checking).  _dump must return a String
0091 # containing the information necessary to reconstitute the object.
0092 # 
0093 # The class method _load should take a String and use it to return an object
0094 # of the same class.
0095 # 
0096 # Example:
0097 # 
0098 #   class MyObj
0099 #     def initialize name, version, data
0100 #       @name    = name
0101 #       @version = version
0102 #       @data    = data
0103 #     end
0104 # 
0105 #     def _dump level
0106 #       [@name, @version].join ':'
0107 #     end
0108 # 
0109 #     def self._load args
0110 #       new(*args.split(':'))
0111 #     end
0112 #   end
0113 # 
0114 # Since Marhsal.dump outputs a string you can have _dump return a Marshal
0115 # string which is Marshal.loaded in _load for complex objects.
0116 module Marshal
0117 ##
0118 # Serializes obj and all descendant objects. If anIO is
0119 # specified, the serialized data will be written to it, otherwise the
0120 # data will be returned as a String. If limit is specified, the
0121 # traversal of subobjects will be limited to that depth. If limit is
0122 # negative, no checking of depth will be performed.
0123 # 
0124 #     class Klass
0125 #       def initialize(str)
0126 #         @str = str
0127 #       end
0128 #       def say_hello
0129 #         @str
0130 #       end
0131 #     end
0132 # 
0133 # (produces no output)
0134 # 
0135 #     o = Klass.new("hello\n")
0136 #     data = Marshal.dump(o)
0137 #     obj = Marshal.load(data)
0138 #     obj.say_hello  #=> "hello\n"
0139 # 
0140 # Marshal can't dump following objects:
0141 # * anonymous Class/Module.
0142 # * objects which related to its system (ex: Dir, File::Stat, IO, File, Socket
0143 #   and so on)
0144 # * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread,
0145 #   ThreadGroup, Continuation
0146 # * objects which defines singleton methods
0147 def self.dump( obj  , limit=-1 , anIO=0); ''; end
0148 ##
0149 # Returns the result of converting the serialized data in source into a
0150 # Ruby object (possibly with associated subordinate objects). source
0151 # may be either an instance of IO or an object that responds to
0152 # to_str. If proc is specified, it will be passed each object as it
0153 # is deserialized.
0154 # 
0155 # Never pass untrusted data (including user supplied input) to this method.
0156 # Please see the overview for further details.
0157 def self.load( source  , proc=0); Object.new; end
0158 ##
0159 # Returns the result of converting the serialized data in source into a
0160 # Ruby object (possibly with associated subordinate objects). source
0161 # may be either an instance of IO or an object that responds to
0162 # to_str. If proc is specified, it will be passed each object as it
0163 # is deserialized.
0164 # 
0165 # Never pass untrusted data (including user supplied input) to this method.
0166 # Please see the overview for further details.
0167 def self.restore( source  , proc=0); Object.new; end
0168 end
0169 
0170 module Kernel
0171 ##
0172 # Equivalent to <code>Proc.new</code>.
0173 def proc(&block); Proc.new; end
0174 ##
0175 # Equivalent to <code>Proc.new</code>, except the resulting Proc objects
0176 # check the number of parameters passed when called.
0177 def lambda(&block); Proc.new; end
0178 ##
0179 # Returns a +Binding+ object, describing the variable and
0180 # method bindings at the point of call. This object can be used when
0181 # calling +eval+ to execute the evaluated command in this
0182 # environment. See also the description of class +Binding+.
0183 # 
0184 #    def get_binding(param)
0185 #      return binding
0186 #    end
0187 #    b = get_binding("hello")
0188 #    eval("param", b)   #=> "hello"
0189 def binding; Binding.new; end
0190 ##
0191 # Returns x/y;
0192 # 
0193 #    Rational(1, 2)   #=> (1/2)
0194 #    Rational('1/2')  #=> (1/2)
0195 # 
0196 # Syntax of string form:
0197 # 
0198 #   string form = extra spaces , rational , extra spaces ;
0199 #   rational = [ sign ] , unsigned rational ;
0200 #   unsigned rational = numerator | numerator , "/" , denominator ;
0201 #   numerator = integer part | fractional part | integer part , fractional part ;
0202 #   denominator = digits ;
0203 #   integer part = digits ;
0204 #   fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
0205 #   sign = "-" | "+" ;
0206 #   digits = digit , { digit | "_" , digit } ;
0207 #   digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
0208 #   extra spaces = ? \s* ? ;
0209 # 
0210 # See String#to_r.
0211 def Rational(x, y=0); 0; end
0212 ##
0213 # Seeds the system pseudo-random number generator, Random::DEFAULT, with
0214 # +number+.  The previous seed value is returned.
0215 # 
0216 # If +number+ is omitted, seeds the generator using a source of entropy
0217 # provided by the operating system, if available (/dev/urandom on Unix systems
0218 # or the RSA cryptographic provider on Windows), which is then combined with
0219 # the time, the process id, and a sequence number.
0220 # 
0221 # srand may be used to ensure repeatable sequences of pseudo-random numbers
0222 # between different runs of the program. By setting the seed to a known value,
0223 # programs can be made deterministic during testing.
0224 # 
0225 #   srand 1234               # => 268519324636777531569100071560086917274
0226 #   [ rand, rand ]           # => [0.1915194503788923, 0.6221087710398319]
0227 #   [ rand(10), rand(1000) ] # => [4, 664]
0228 #   srand 1234               # => 1234
0229 #   [ rand, rand ]           # => [0.1915194503788923, 0.6221087710398319]
0230 def srand(number = Random.new_seed); 1; end
0231 ##
0232 # If called without an argument, or if <tt>max.to_i.abs == 0</tt>, rand
0233 # returns a pseudo-random floating point number between 0.0 and 1.0,
0234 # including 0.0 and excluding 1.0.
0235 # 
0236 #   rand        #=> 0.2725926052826416
0237 # 
0238 # When +max.abs+ is greater than or equal to 1, +rand+ returns a pseudo-random
0239 # integer greater than or equal to 0 and less than +max.to_i.abs+.
0240 # 
0241 #   rand(100)   #=> 12
0242 # 
0243 # When +max+ is a Range, +rand+ returns a random number where
0244 # range.member?(number) == true.
0245 # 
0246 # Negative or floating point values for +max+ are allowed, but may give
0247 # surprising results.
0248 # 
0249 #   rand(-100) # => 87
0250 #   rand(-0.5) # => 0.8130921818028143
0251 #   rand(1.9)  # equivalent to rand(1), which is always 0
0252 # 
0253 # Kernel.srand may be used to ensure that sequences of random numbers are
0254 # reproducible between different runs of a program.
0255 # 
0256 # See also Random.rand.
0257 def rand(max=0); 0; end
0258 ##
0259 # Evaluates the Ruby expression(s) in <em>string</em>. If
0260 # <em>binding</em> is given, which must be a <code>Binding</code>
0261 # object, the evaluation is performed in its context. If the
0262 # optional <em>filename</em> and <em>lineno</em> parameters are
0263 # present, they will be used when reporting syntax errors.
0264 # 
0265 #    def get_binding(str)
0266 #      return binding
0267 #    end
0268 #    str = "hello"
0269 #    eval "str + ' Fred'"                      #=> "hello Fred"
0270 #    eval "str + ' Fred'", get_binding("bye")  #=> "bye Fred"
0271 def eval(string , binding=0, filename=0, lineno=0); Object.new; end
0272 ##
0273 # Returns the names of the current local variables.
0274 # 
0275 #    fred = 1
0276 #    for i in 1..10
0277 #       # ...
0278 #    end
0279 #    local_variables   #=> [:fred, :i]
0280 def local_variables; []; end
0281 ##
0282 # Returns <code>true</code> if <code>yield</code> would execute a
0283 # block in the current context. The <code>iterator?</code> form
0284 # is mildly deprecated.
0285 # 
0286 #    def try
0287 #      if block_given?
0288 #        yield
0289 #      else
0290 #        "no block"
0291 #      end
0292 #    end
0293 #    try                  #=> "no block"
0294 #    try { "hello" }      #=> "hello"
0295 #    try do "hello" end   #=> "hello"
0296 def iterator?; true || false; end
0297 ##
0298 # Returns <code>true</code> if <code>yield</code> would execute a
0299 # block in the current context. The <code>iterator?</code> form
0300 # is mildly deprecated.
0301 # 
0302 #    def try
0303 #      if block_given?
0304 #        yield
0305 #      else
0306 #        "no block"
0307 #      end
0308 #    end
0309 #    try                  #=> "no block"
0310 #    try { "hello" }      #=> "hello"
0311 #    try do "hello" end   #=> "hello"
0312 def block_given?; true || false; end
0313 ##
0314 # +catch+ executes its block. If a +throw+ is
0315 # executed, Ruby searches up its stack for a +catch+ block
0316 # with a tag corresponding to the +throw+'s
0317 # _tag_. If found, that block is terminated, and
0318 # +catch+ returns the value given to +throw+. If
0319 # +throw+ is not called, the block terminates normally, and
0320 # the value of +catch+ is the value of the last expression
0321 # evaluated. +catch+ expressions may be nested, and the
0322 # +throw+ call need not be in lexical scope.
0323 # 
0324 #    def routine(n)
0325 #      puts n
0326 #      throw :done if n <= 0
0327 #      routine(n-1)
0328 #    end
0329 # 
0330 #    catch(:done) { routine(3) }
0331 # 
0332 # <em>produces:</em>
0333 # 
0334 #    3
0335 #    2
0336 #    1
0337 #    0
0338 # 
0339 # when _arg_ is given, +catch+ yields it as is, or when no
0340 # _arg_ is given, +catch+ assigns a new unique object to
0341 # +throw+.  this is useful for nested +catch+.  _arg_ can
0342 # be an arbitrary object, not only Symbol.
0343 def catch(arg=0, &block); Object.new; end
0344 ##
0345 # Transfers control to the end of the active +catch+ block
0346 # waiting for _tag_. Raises +ArgumentError+ if there
0347 # is no +catch+ block for the _tag_. The optional second
0348 # parameter supplies a return value for the +catch+ block,
0349 # which otherwise defaults to +nil+. For examples, see
0350 # <code>Kernel::catch</code>.
0351 def throw(tag , obj=0); end
0352 ##
0353 # Repeatedly executes the block.
0354 # 
0355 # If no block is given, an enumerator is returned instead.
0356 # 
0357 #    loop do
0358 #      print "Input: "
0359 #      line = gets
0360 #      break if !line or line =~ /^qQ/
0361 #      # ...
0362 #    end
0363 # 
0364 # StopIteration raised in the block breaks the loop.
0365 def loop(&block); Enumerator.new; end
0366 ##
0367 # Equivalent to <code>$_.sub(<i>args</i>)</code>, except that
0368 # <code>$_</code> will be updated if substitution occurs.
0369 # Available only when -p/-n command line option specified.
0370 def sub(pattern, replacement); $_; end
0371 ##
0372 # Equivalent to <code>$_.gsub...</code>, except that <code>$_</code>
0373 # receives the modified result.
0374 # Available only when -p/-n command line option specified.
0375 def gsub(pattern, replacement); ''; end
0376 ##
0377 # Equivalent to <code>($_.dup).chop!</code>, except <code>nil</code>
0378 # is never returned. See <code>String#chop!</code>.
0379 # Available only when -p/-n command line option specified.
0380 def chop; ''; end
0381 ##
0382 # Equivalent to <code>$_ = $_.chomp(<em>string</em>)</code>. See
0383 # <code>String#chomp</code>.
0384 # Available only when -p/-n command line option specified.
0385 def chomp; $_; end
0386 ##
0387 # With no arguments, raises the exception in <code>$!</code> or raises
0388 # a <code>RuntimeError</code> if <code>$!</code> is +nil+.
0389 # With a single +String+ argument, raises a
0390 # +RuntimeError+ with the string as a message. Otherwise,
0391 # the first parameter should be the name of an +Exception+
0392 # class (or an object that returns an +Exception+ object when sent
0393 # an +exception+ message). The optional second parameter sets the
0394 # message associated with the exception, and the third parameter is an
0395 # array of callback information. Exceptions are caught by the
0396 # +rescue+ clause of <code>begin...end</code> blocks.
0397 # 
0398 #    raise "Failed to create socket"
0399 #    raise ArgumentError, "No parameters", caller
0400 def raise; end
0401 ##
0402 # With no arguments, raises the exception in <code>$!</code> or raises
0403 # a <code>RuntimeError</code> if <code>$!</code> is +nil+.
0404 # With a single +String+ argument, raises a
0405 # +RuntimeError+ with the string as a message. Otherwise,
0406 # the first parameter should be the name of an +Exception+
0407 # class (or an object that returns an +Exception+ object when sent
0408 # an +exception+ message). The optional second parameter sets the
0409 # message associated with the exception, and the third parameter is an
0410 # array of callback information. Exceptions are caught by the
0411 # +rescue+ clause of <code>begin...end</code> blocks.
0412 # 
0413 #    raise "Failed to create socket"
0414 #    raise ArgumentError, "No parameters", caller
0415 def fail; end
0416 ##
0417 # Returns an array of the names of global variables.
0418 # 
0419 #    global_variables.grep /std/   #=> [:$stdin, :$stdout, :$stderr]
0420 def global_variables; []; end
0421 ##
0422 # Returns the name of the current method as a Symbol.
0423 # If called outside of a method, it returns <code>nil</code>.
0424 def __method__; :a; end
0425 ##
0426 # Returns the canonicalized absolute path of the directory of the file from
0427 # which this method is called. It means symlinks in the path is resolved.
0428 # If <code>__FILE__</code> is <code>nil</code>, it returns <code>nil</code>.
0429 # The return value equals to <code>File.dirname(File.realpath(__FILE__))</code>.
0430 def __dir__; ''; end
0431 ##
0432 # Controls tracing of assignments to global variables. The parameter
0433 # +symbol_ identifies the variable (as either a string name or a
0434 # symbol identifier). _cmd_ (which may be a string or a
0435 # +Proc+ object) or block is executed whenever the variable
0436 # is assigned. The block or +Proc+ object receives the
0437 # variable's new value as a parameter. Also see
0438 # <code>Kernel::untrace_var</code>.
0439 # 
0440 #    trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
0441 #    $_ = "hello"
0442 #    $_ = ' there'
0443 # 
0444 # <em>produces:</em>
0445 # 
0446 #    $_ is now 'hello'
0447 #    $_ is now ' there'
0448 def trace_var(symbol, cmd ); end
0449 ##
0450 # Removes tracing for the specified command on the given global
0451 # variable and returns +nil+. If no command is specified,
0452 # removes all tracing for that variable and returns an array
0453 # containing the commands actually removed.
0454 def untrace_var(symbol  , cmd=0); [] || nil; end
0455 ##
0456 # Displays each of the given messages followed by a record separator on
0457 # STDERR unless warnings have been disabled (for example with the
0458 # <code>-W0</code> flag).
0459 # 
0460 #    warn("warning 1", "warning 2")
0461 # 
0462 #  <em>produces:</em>
0463 # 
0464 #    warning 1
0465 #    warning 2
0466 def warn(); end
0467 ##
0468 # Returns the current execution stack---an array containing strings in
0469 # the form <code>file:line</code> or <code>file:line: in
0470 # `method'</code>.
0471 # 
0472 # The optional _start_ parameter determines the number of initial stack
0473 # entries to omit from the top of the stack.
0474 # 
0475 # A second optional +length+ parameter can be used to limit how many entries
0476 # are returned from the stack.
0477 # 
0478 # Returns +nil+ if _start_ is greater than the size of
0479 # current execution stack.
0480 # 
0481 # Optionally you can pass a range, which will return an array containing the
0482 # entries within the specified range.
0483 # 
0484 #    def a(skip)
0485 #      caller(skip)
0486 #    end
0487 #    def b(skip)
0488 #      a(skip)
0489 #    end
0490 #    def c(skip)
0491 #      b(skip)
0492 #    end
0493 #    c(0)   #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `<main>'"]
0494 #    c(1)   #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `<main>'"]
0495 #    c(2)   #=> ["prog:8:in `c'", "prog:12:in `<main>'"]
0496 #    c(3)   #=> ["prog:13:in `<main>'"]
0497 #    c(4)   #=> []
0498 #    c(5)   #=> nil
0499 def caller(start=1, length=null); [] || nil; end
0500 ##
0501 # Returns the current execution stack---an array containing
0502 # backtrace location objects.
0503 # 
0504 # See Thread::Backtrace::Location for more information.
0505 # 
0506 # The optional _start_ parameter determines the number of initial stack
0507 # entries to omit from the top of the stack.
0508 # 
0509 # A second optional +length+ parameter can be used to limit how many entries
0510 # are returned from the stack.
0511 # 
0512 # Returns +nil+ if _start_ is greater than the size of
0513 # current execution stack.
0514 # 
0515 # Optionally you can pass a range, which will return an array containing the
0516 # entries within the specified range.
0517 def caller_locations(start=1, length=null); [] || nil; end
0518 ##
0519 # Uses the integer +int_cmd+ to perform various tests on +file1+ (first
0520 # table below) or on +file1+ and +file2+ (second table).
0521 # 
0522 # File tests on a single file:
0523 # 
0524 #   Test   Returns   Meaning
0525 #   "A"  | Time    | Last access time for file1
0526 #   "b"  | boolean | True if file1 is a block device
0527 #   "c"  | boolean | True if file1 is a character device
0528 #   "C"  | Time    | Last change time for file1
0529 #   "d"  | boolean | True if file1 exists and is a directory
0530 #   "e"  | boolean | True if file1 exists
0531 #   "f"  | boolean | True if file1 exists and is a regular file
0532 #   "g"  | boolean | True if file1 has the \CF{setgid} bit
0533 #        |         | set (false under NT)
0534 #   "G"  | boolean | True if file1 exists and has a group
0535 #        |         | ownership equal to the caller's group
0536 #   "k"  | boolean | True if file1 exists and has the sticky bit set
0537 #   "l"  | boolean | True if file1 exists and is a symbolic link
0538 #   "M"  | Time    | Last modification time for file1
0539 #   "o"  | boolean | True if file1 exists and is owned by
0540 #        |         | the caller's effective uid
0541 #   "O"  | boolean | True if file1 exists and is owned by
0542 #        |         | the caller's real uid
0543 #   "p"  | boolean | True if file1 exists and is a fifo
0544 #   "r"  | boolean | True if file1 is readable by the effective
0545 #        |         | uid/gid of the caller
0546 #   "R"  | boolean | True if file is readable by the real
0547 #        |         | uid/gid of the caller
0548 #   "s"  | int/nil | If file1 has nonzero size, return the size,
0549 #        |         | otherwise return nil
0550 #   "S"  | boolean | True if file1 exists and is a socket
0551 #   "u"  | boolean | True if file1 has the setuid bit set
0552 #   "w"  | boolean | True if file1 exists and is writable by
0553 #        |         | the effective uid/gid
0554 #   "W"  | boolean | True if file1 exists and is writable by
0555 #        |         | the real uid/gid
0556 #   "x"  | boolean | True if file1 exists and is executable by
0557 #        |         | the effective uid/gid
0558 #   "X"  | boolean | True if file1 exists and is executable by
0559 #        |         | the real uid/gid
0560 #   "z"  | boolean | True if file1 exists and has a zero length
0561 # 
0562 # Tests that take two files:
0563 # 
0564 #   "-"  | boolean | True if file1 and file2 are identical
0565 #   "="  | boolean | True if the modification times of file1
0566 #        |         | and file2 are equal
0567 #   "<"  | boolean | True if the modification time of file1
0568 #        |         | is prior to that of file2
0569 #   ">"  | boolean | True if the modification time of file1
0570 #        |         | is after that of file2
0571 def test(int_cmd, file1  , file2=0); Object.new; end
0572 ##
0573 # Establishes _proc_ as the handler for tracing, or disables
0574 # tracing if the parameter is +nil+.
0575 # 
0576 # *Note:* this method is obsolete, please use TracePoint instead.
0577 # 
0578 # _proc_ takes up to six parameters:
0579 # 
0580 # *   an event name
0581 # *   a filename
0582 # *   a line number
0583 # *   an object id
0584 # *   a binding
0585 # *   the name of a class
0586 # 
0587 # _proc_ is invoked whenever an event occurs.
0588 # 
0589 # Events are:
0590 # 
0591 # +c-call+:: call a C-language routine
0592 # +c-return+:: return from a C-language routine
0593 # +call+:: call a Ruby method
0594 # +class+:: start a class or module definition),
0595 # +end+:: finish a class or module definition),
0596 # +line+:: execute code on a new line
0597 # +raise+:: raise an exception
0598 # +return+:: return from a Ruby method
0599 # 
0600 # Tracing is disabled within the context of _proc_.
0601 # 
0602 #     class Test
0603 #     def test
0604 #       a = 1
0605 #       b = 2
0606 #     end
0607 #     end
0608 # 
0609 #     set_trace_func proc { |event, file, line, id, binding, classname|
0610 #        printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
0611 #     }
0612 #     t = Test.new
0613 #     t.test
0614 # 
0615 #       line prog.rb:11               false
0616 #     c-call prog.rb:11        new    Class
0617 #     c-call prog.rb:11 initialize   Object
0618 #   c-return prog.rb:11 initialize   Object
0619 #   c-return prog.rb:11        new    Class
0620 #       line prog.rb:12               false
0621 #       call prog.rb:2        test     Test
0622 #       line prog.rb:3        test     Test
0623 #       line prog.rb:4        test     Test
0624 #     return prog.rb:4        test     Test
0625 def set_trace_func(proc); end
0626 ##
0627 # Replaces the current process by running the given external _command_.
0628 # _command..._ is one of following forms.
0629 # 
0630 #   commandline                 : command line string which is passed to the standard shell
0631 #   cmdname, arg1, ...          : command name and one or more arguments (no shell)
0632 #   [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
0633 # 
0634 # If single string is given as the command,
0635 # it is taken as a command line that is subject to shell expansion before being executed.
0636 # 
0637 # The standard shell means always <code>"/bin/sh"</code> on Unix-like systems,
0638 # <code>ENV["RUBYSHELL"]</code> or <code>ENV["COMSPEC"]</code> on Windows NT series, and
0639 # similar.
0640 # 
0641 # If two or more +string+ given,
0642 # the first is taken as a command name and
0643 # the rest are passed as parameters to command with no shell expansion.
0644 # 
0645 # If a two-element array at the beginning of the command,
0646 # the first element is the command to be executed,
0647 # and the second argument is used as the <code>argv[0]</code> value,
0648 # which may show up in process listings.
0649 # 
0650 # In order to execute the command, one of the <code>exec(2)</code>
0651 # system calls is used, so the running command may inherit some of the environment
0652 # of the original program (including open file descriptors).
0653 # This behavior is modified by env and options.
0654 # See <code>spawn</code> for details.
0655 # 
0656 # Raises SystemCallError if the command couldn't execute (typically
0657 # <code>Errno::ENOENT</code> when it was not found).
0658 # 
0659 # This method modifies process attributes according to _options_
0660 # (details described in <code>spawn</code>)
0661 # before <code>exec(2)</code> system call.
0662 # The modified attributes may be retained when <code>exec(2)</code> system call fails.
0663 # For example, hard resource limits is not restorable.
0664 # If it is not acceptable, consider to create a child process using <code>spawn</code> or <code>system</code>.
0665 # 
0666 #    exec "echo *"       # echoes list of files in current directory
0667 #    # never get here
0668 # 
0669 #    exec "echo", "*"    # echoes an asterisk
0670 #    # never get here
0671 def exec(env=0, command=0, options=0); end
0672 ##
0673 # Creates a subprocess. If a block is specified, that block is run
0674 # in the subprocess, and the subprocess terminates with a status of
0675 # zero. Otherwise, the +fork+ call returns twice, once in
0676 # the parent, returning the process ID of the child, and once in
0677 # the child, returning _nil_. The child process can exit using
0678 # <code>Kernel.exit!</code> to avoid running any
0679 # <code>at_exit</code> functions. The parent process should
0680 # use <code>Process.wait</code> to collect the termination statuses
0681 # of its children or use <code>Process.detach</code> to register
0682 # disinterest in their status; otherwise, the operating system
0683 # may accumulate zombie processes.
0684 # 
0685 # The thread calling fork is the only thread in the created child process.
0686 # fork doesn't copy other threads.
0687 # 
0688 # If fork is not usable, Process.respond_to?(:fork) returns false.
0689 def fork; 1 || nil; end
0690 ##
0691 # Exits the process immediately. No exit handlers are
0692 # run. <em>status</em> is returned to the underlying system as the
0693 # exit status.
0694 # 
0695 #    Process.exit!(true)
0696 def exit!(status=false); end
0697 ##
0698 # Executes _command..._ in a subshell.
0699 # _command..._ is one of following forms.
0700 # 
0701 #   commandline                 : command line string which is passed to the standard shell
0702 #   cmdname, arg1, ...          : command name and one or more arguments (no shell)
0703 #   [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
0704 # 
0705 # system returns +true+ if the command gives zero exit status,
0706 # +false+ for non zero exit status.
0707 # Returns +nil+ if command execution fails.
0708 # An error status is available in <code>$?</code>.
0709 # The arguments are processed in the same way as
0710 # for <code>Kernel.spawn</code>.
0711 # 
0712 # The hash arguments, env and options, are same as
0713 # <code>exec</code> and <code>spawn</code>.
0714 # See <code>Kernel.spawn</code> for details.
0715 # 
0716 #    system("echo *")
0717 #    system("echo", "*")
0718 # 
0719 # <em>produces:</em>
0720 # 
0721 #    config.h main.rb
0722 #    *
0723 # 
0724 # See <code>Kernel.exec</code> for the standard shell.
0725 def system(env=0, command=0, options=0); true || false || nil; end
0726 ##
0727 # spawn executes specified command and return its pid.
0728 # 
0729 # This method doesn't wait for end of the command.
0730 # The parent process should
0731 # use <code>Process.wait</code> to collect
0732 # the termination status of its child or
0733 # use <code>Process.detach</code> to register
0734 # disinterest in their status;
0735 # otherwise, the operating system may accumulate zombie processes.
0736 # 
0737 # spawn has bunch of options to specify process attributes:
0738 # 
0739 #   env: hash
0740 #     name => val : set the environment variable
0741 #     name => nil : unset the environment variable
0742 #   command...:
0743 #     commandline                 : command line string which is passed to the standard shell
0744 #     cmdname, arg1, ...          : command name and one or more arguments (no shell)
0745 #     [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
0746 #   options: hash
0747 #     clearing environment variables:
0748 #       :unsetenv_others => true   : clear environment variables except specified by env
0749 #       :unsetenv_others => false  : don't clear (default)
0750 #     process group:
0751 #       :pgroup => true or 0 : make a new process group
0752 #       :pgroup => pgid      : join to specified process group
0753 #       :pgroup => nil       : don't change the process group (default)
0754 #     create new process group: Windows only
0755 #       :new_pgroup => true  : the new process is the root process of a new process group
0756 #       :new_pgroup => false : don't create a new process group (default)
0757 #     resource limit: resourcename is core, cpu, data, etc.  See Process.setrlimit.
0758 #       :rlimit_resourcename => limit
0759 #       :rlimit_resourcename => [cur_limit, max_limit]
0760 #     umask:
0761 #       :umask => int
0762 #     redirection:
0763 #       key:
0764 #         FD              : single file descriptor in child process
0765 #         [FD, FD, ...]   : multiple file descriptor in child process
0766 #       value:
0767 #         FD                        : redirect to the file descriptor in parent process
0768 #         string                    : redirect to file with open(string, "r" or "w")
0769 #         [string]                  : redirect to file with open(string, File::RDONLY)
0770 #         [string, open_mode]       : redirect to file with open(string, open_mode, 0644)
0771 #         [string, open_mode, perm] : redirect to file with open(string, open_mode, perm)
0772 #         [:child, FD]              : redirect to the redirected file descriptor
0773 #         :close                    : close the file descriptor in child process
0774 #       FD is one of follows
0775 #         :in     : the file descriptor 0 which is the standard input
0776 #         :out    : the file descriptor 1 which is the standard output
0777 #         :err    : the file descriptor 2 which is the standard error
0778 #         integer : the file descriptor of specified the integer
0779 #         io      : the file descriptor specified as io.fileno
0780 #     file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not
0781 #       :close_others => true  : don't inherit
0782 #     current directory:
0783 #       :chdir => str
0784 # 
0785 # If a hash is given as +env+, the environment is
0786 # updated by +env+ before <code>exec(2)</code> in the child process.
0787 # If a pair in +env+ has nil as the value, the variable is deleted.
0788 # 
0789 #   # set FOO as BAR and unset BAZ.
0790 #   pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
0791 # 
0792 # If a hash is given as +options+,
0793 # it specifies
0794 # process group,
0795 # create new process group,
0796 # resource limit,
0797 # current directory,
0798 # umask and
0799 # redirects for the child process.
0800 # Also, it can be specified to clear environment variables.
0801 # 
0802 # The <code>:unsetenv_others</code> key in +options+ specifies
0803 # to clear environment variables, other than specified by +env+.
0804 # 
0805 #   pid = spawn(command, :unsetenv_others=>true) # no environment variable
0806 #   pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only
0807 # 
0808 # The <code>:pgroup</code> key in +options+ specifies a process group.
0809 # The corresponding value should be true, zero or positive integer.
0810 # true and zero means the process should be a process leader of a new
0811 # process group.
0812 # Other values specifies a process group to be belongs.
0813 # 
0814 #   pid = spawn(command, :pgroup=>true) # process leader
0815 #   pid = spawn(command, :pgroup=>10) # belongs to the process group 10
0816 # 
0817 # The <code>:new_pgroup</code> key in +options+ specifies to pass
0818 # +CREATE_NEW_PROCESS_GROUP+ flag to <code>CreateProcessW()</code> that is
0819 # Windows API. This option is only for Windows.
0820 # true means the new process is the root process of the new process group.
0821 # The new process has CTRL+C disabled. This flag is necessary for
0822 # <code>Process.kill(:SIGINT, pid)</code> on the subprocess.
0823 # :new_pgroup is false by default.
0824 # 
0825 #   pid = spawn(command, :new_pgroup=>true)  # new process group
0826 #   pid = spawn(command, :new_pgroup=>false) # same process group
0827 # 
0828 # The <code>:rlimit_</code><em>foo</em> key specifies a resource limit.
0829 # <em>foo</em> should be one of resource types such as <code>core</code>.
0830 # The corresponding value should be an integer or an array which have one or
0831 # two integers: same as cur_limit and max_limit arguments for
0832 # Process.setrlimit.
0833 # 
0834 #   cur, max = Process.getrlimit(:CORE)
0835 #   pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary.
0836 #   pid = spawn(command, :rlimit_core=>max) # enable core dump
0837 #   pid = spawn(command, :rlimit_core=>0) # never dump core.
0838 # 
0839 # The <code>:umask</code> key in +options+ specifies the umask.
0840 # 
0841 #   pid = spawn(command, :umask=>077)
0842 # 
0843 # The :in, :out, :err, a fixnum, an IO and an array key specifies a redirection.
0844 # The redirection maps a file descriptor in the child process.
0845 # 
0846 # For example, stderr can be merged into stdout as follows:
0847 # 
0848 #   pid = spawn(command, :err=>:out)
0849 #   pid = spawn(command, 2=>1)
0850 #   pid = spawn(command, STDERR=>:out)
0851 #   pid = spawn(command, STDERR=>STDOUT)
0852 # 
0853 # The hash keys specifies a file descriptor
0854 # in the child process started by <code>spawn</code>.
0855 # :err, 2 and STDERR specifies the standard error stream (stderr).
0856 # 
0857 # The hash values specifies a file descriptor
0858 # in the parent process which invokes <code>spawn</code>.
0859 # :out, 1 and STDOUT specifies the standard output stream (stdout).
0860 # 
0861 # In the above example,
0862 # the standard output in the child process is not specified.
0863 # So it is inherited from the parent process.
0864 # 
0865 # The standard input stream (stdin) can be specified by :in, 0 and STDIN.
0866 # 
0867 # A filename can be specified as a hash value.
0868 # 
0869 #   pid = spawn(command, :in=>"/dev/null") # read mode
0870 #   pid = spawn(command, :out=>"/dev/null") # write mode
0871 #   pid = spawn(command, :err=>"log") # write mode
0872 #   pid = spawn(command, 3=>"/dev/null") # read mode
0873 # 
0874 # For stdout and stderr,
0875 # it is opened in write mode.
0876 # Otherwise read mode is used.
0877 # 
0878 # For specifying flags and permission of file creation explicitly,
0879 # an array is used instead.
0880 # 
0881 #   pid = spawn(command, :in=>["file"]) # read mode is assumed
0882 #   pid = spawn(command, :in=>["file", "r"])
0883 #   pid = spawn(command, :out=>["log", "w"]) # 0644 assumed
0884 #   pid = spawn(command, :out=>["log", "w", 0600])
0885 #   pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600])
0886 # 
0887 # The array specifies a filename, flags and permission.
0888 # The flags can be a string or an integer.
0889 # If the flags is omitted or nil, File::RDONLY is assumed.
0890 # The permission should be an integer.
0891 # If the permission is omitted or nil, 0644 is assumed.
0892 # 
0893 # If an array of IOs and integers are specified as a hash key,
0894 # all the elements are redirected.
0895 # 
0896 #   # stdout and stderr is redirected to log file.
0897 #   # The file "log" is opened just once.
0898 #   pid = spawn(command, [:out, :err]=>["log", "w"])
0899 # 
0900 # Another way to merge multiple file descriptors is [:child, fd].
0901 # \[:child, fd] means the file descriptor in the child process.
0902 # This is different from fd.
0903 # For example, :err=>:out means redirecting child stderr to parent stdout.
0904 # But :err=>[:child, :out] means redirecting child stderr to child stdout.
0905 # They differ if stdout is redirected in the child process as follows.
0906 # 
0907 #   # stdout and stderr is redirected to log file.
0908 #   # The file "log" is opened just once.
0909 #   pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out])
0910 # 
0911 # \[:child, :out] can be used to merge stderr into stdout in IO.popen.
0912 # In this case, IO.popen redirects stdout to a pipe in the child process
0913 # and [:child, :out] refers the redirected stdout.
0914 # 
0915 #   io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
0916 #   p io.read #=> "out\nerr\n"
0917 # 
0918 # The <code>:chdir</code> key in +options+ specifies the current directory.
0919 # 
0920 #   pid = spawn(command, :chdir=>"/var/tmp")
0921 # 
0922 # spawn closes all non-standard unspecified descriptors by default.
0923 # The "standard" descriptors are 0, 1 and 2.
0924 # This behavior is specified by :close_others option.
0925 # :close_others doesn't affect the standard descriptors which are
0926 # closed only if :close is specified explicitly.
0927 # 
0928 #   pid = spawn(command, :close_others=>true)  # close 3,4,5,... (default)
0929 #   pid = spawn(command, :close_others=>false) # don't close 3,4,5,...
0930 # 
0931 # :close_others is true by default for spawn and IO.popen.
0932 # 
0933 # Note that fds which close-on-exec flag is already set are closed
0934 # regardless of :close_others option.
0935 # 
0936 # So IO.pipe and spawn can be used as IO.popen.
0937 # 
0938 #   # similar to r = IO.popen(command)
0939 #   r, w = IO.pipe
0940 #   pid = spawn(command, :out=>w)   # r, w is closed in the child process.
0941 #   w.close
0942 # 
0943 # :close is specified as a hash value to close a fd individually.
0944 # 
0945 #   f = open(foo)
0946 #   system(command, f=>:close)        # don't inherit f.
0947 # 
0948 # If a file descriptor need to be inherited,
0949 # io=>io can be used.
0950 # 
0951 #   # valgrind has --log-fd option for log destination.
0952 #   # log_w=>log_w indicates log_w.fileno inherits to child process.
0953 #   log_r, log_w = IO.pipe
0954 #   pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w)
0955 #   log_w.close
0956 #   p log_r.read
0957 # 
0958 # It is also possible to exchange file descriptors.
0959 # 
0960 #   pid = spawn(command, :out=>:err, :err=>:out)
0961 # 
0962 # The hash keys specify file descriptors in the child process.
0963 # The hash values specifies file descriptors in the parent process.
0964 # So the above specifies exchanging stdout and stderr.
0965 # Internally, +spawn+ uses an extra file descriptor to resolve such cyclic
0966 # file descriptor mapping.
0967 # 
0968 # See <code>Kernel.exec</code> for the standard shell.
0969 def spawn(env=0, command=0, options=0); 0; end
0970 ##
0971 # Suspends the current thread for _duration_ seconds (which may be any number,
0972 # including a +Float+ with fractional seconds). Returns the actual number of
0973 # seconds slept (rounded), which may be less than that asked for if another
0974 # thread calls <code>Thread#run</code>. Called without an argument, sleep()
0975 # will sleep forever.
0976 # 
0977 #    Time.new    #=> 2008-03-08 19:56:19 +0900
0978 #    sleep 1.2   #=> 1
0979 #    Time.new    #=> 2008-03-08 19:56:20 +0900
0980 #    sleep 1.9   #=> 2
0981 #    Time.new    #=> 2008-03-08 19:56:22 +0900
0982 def sleep(duration=0); 0; end
0983 ##
0984 # Initiates the termination of the Ruby script by raising the
0985 # <code>SystemExit</code> exception. This exception may be caught. The
0986 # optional parameter is used to return a status code to the invoking
0987 # environment.
0988 # +true+ and +FALSE+ of _status_ means success and failure
0989 # respectively.  The interpretation of other integer values are
0990 # system dependent.
0991 # 
0992 #    begin
0993 #      exit
0994 #      puts "never get here"
0995 #    rescue SystemExit
0996 #      puts "rescued a SystemExit exception"
0997 #    end
0998 #    puts "after begin block"
0999 # 
1000 # <em>produces:</em>
1001 # 
1002 #    rescued a SystemExit exception
1003 #    after begin block
1004 # 
1005 # Just prior to termination, Ruby executes any <code>at_exit</code> functions
1006 # (see Kernel::at_exit) and runs any object finalizers (see
1007 # ObjectSpace::define_finalizer).
1008 # 
1009 #    at_exit { puts "at_exit function" }
1010 #    ObjectSpace.define_finalizer("string",  proc { puts "in finalizer" })
1011 #    exit
1012 # 
1013 # <em>produces:</em>
1014 # 
1015 #    at_exit function
1016 #    in finalizer
1017 def exit(status=true); end
1018 ##
1019 # Terminate execution immediately, effectively by calling
1020 # <code>Kernel.exit(false)</code>. If _msg_ is given, it is written
1021 # to STDERR prior to terminating.
1022 def abort; end
1023 ##
1024 # Converts _block_ to a +Proc+ object (and therefore
1025 # binds it at the point of call) and registers it for execution when
1026 # the program exits. If multiple handlers are registered, they are
1027 # executed in reverse order of registration.
1028 # 
1029 #    def do_at_exit(str1)
1030 #      at_exit { print str1 }
1031 #    end
1032 #    at_exit { puts "cruel world" }
1033 #    do_at_exit("goodbye ")
1034 #    exit
1035 # 
1036 # <em>produces:</em>
1037 # 
1038 #    goodbye cruel world
1039 def at_exit(&block); Proc.new; end
1040 ##
1041 # Loads and executes the Ruby
1042 # program in the file _filename_. If the filename does not
1043 # resolve to an absolute path, the file is searched for in the library
1044 # directories listed in <code>$:</code>. If the optional _wrap_
1045 # parameter is +true+, the loaded script will be executed
1046 # under an anonymous module, protecting the calling program's global
1047 # namespace. In no circumstance will any local variables in the loaded
1048 # file be propagated to the loading environment.
1049 def load(filename, wrap=false); true; end
1050 ##
1051 # Loads the given +name+, returning +true+ if successful and +false+ if the
1052 # feature is already loaded.
1053 # 
1054 # If the filename does not resolve to an absolute path, it will be searched
1055 # for in the directories listed in <code>$LOAD_PATH</code> (<code>$:</code>).
1056 # 
1057 # If the filename has the extension ".rb", it is loaded as a source file; if
1058 # the extension is ".so", ".o", or ".dll", or the default shared library
1059 # extension on the current platform, Ruby loads the shared library as a
1060 # Ruby extension.  Otherwise, Ruby tries adding ".rb", ".so", and so on
1061 # to the name until found.  If the file named cannot be found, a LoadError
1062 # will be raised.
1063 # 
1064 # For Ruby extensions the filename given may use any shared library
1065 # extension.  For example, on Linux the socket extension is "socket.so" and
1066 # <code>require 'socket.dll'</code> will load the socket extension.
1067 # 
1068 # The absolute path of the loaded file is added to
1069 # <code>$LOADED_FEATURES</code> (<code>$"</code>).  A file will not be
1070 # loaded again if its path already appears in <code>$"</code>.  For example,
1071 # <code>require 'a'; require './a'</code> will not load <code>a.rb</code>
1072 # again.
1073 # 
1074 #   require "my-library.rb"
1075 #   require "db-driver"
1076 # 
1077 # Any constants or globals within the loaded source file will be available
1078 # in the calling program's global namespace. However, local variables will
1079 # not be propagated to the loading environment.
1080 def require(name); true || false; end
1081 ##
1082 # Ruby tries to load the library named _string_ relative to the requiring
1083 # file's path.  If the file's path cannot be determined a LoadError is raised.
1084 # If a file is loaded +true+ is returned and false otherwise.
1085 def require_relative(string); true || false; end
1086 ##
1087 # Registers _filename_ to be loaded (using <code>Kernel::require</code>)
1088 # the first time that _module_ (which may be a <code>String</code> or
1089 # a symbol) is accessed.
1090 # 
1091 #    autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
1092 def autoload(modul, filename); end
1093 ##
1094 # Returns _filename_ to be loaded if _name_ is registered as
1095 # +autoload+.
1096 # 
1097 #    autoload(:B, "b")
1098 #    autoload?(:B)            #=> "b"
1099 def autoload?(name); '' || nil; end
1100 ##
1101 # Specifies the handling of signals. The first parameter is a signal
1102 # name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
1103 # signal number. The characters ``SIG'' may be omitted from the
1104 # signal name. The command or block specifies code to be run when the
1105 # signal is raised.
1106 # If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
1107 # will be ignored.
1108 # If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
1109 # will be invoked.
1110 # If the command is ``EXIT'', the script will be terminated by the signal.
1111 # If the command is ``SYSTEM_DEFAULT'', the operating system's default
1112 # handler will be invoked.
1113 # Otherwise, the given command or block will be run.
1114 # The special signal name ``EXIT'' or signal number zero will be
1115 # invoked just prior to program termination.
1116 # trap returns the previous handler for the given signal.
1117 # 
1118 #     Signal.trap(0, proc { puts "Terminating: #{$$}" })
1119 #     Signal.trap("CLD")  { puts "Child died" }
1120 #     fork && Process.wait
1121 # 
1122 # produces:
1123 #     Terminating: 27461
1124 #     Child died
1125 #     Terminating: 27460
1126 def trap( signal, command ); Object.new; end
1127 ##
1128 # Returns the string resulting from applying <i>format_string</i> to
1129 # any additional arguments.  Within the format string, any characters
1130 # other than format sequences are copied to the result.
1131 # 
1132 # The syntax of a format sequence is follows.
1133 # 
1134 #   %[flags][width][.precision]type
1135 # 
1136 # A format
1137 # sequence consists of a percent sign, followed by optional flags,
1138 # width, and precision indicators, then terminated with a field type
1139 # character.  The field type controls how the corresponding
1140 # <code>sprintf</code> argument is to be interpreted, while the flags
1141 # modify that interpretation.
1142 # 
1143 # The field type characters are:
1144 # 
1145 #     Field |  Integer Format
1146 #     ------+--------------------------------------------------------------
1147 #       b   | Convert argument as a binary number.
1148 #           | Negative numbers will be displayed as a two's complement
1149 #           | prefixed with `..1'.
1150 #       B   | Equivalent to `b', but uses an uppercase 0B for prefix
1151 #           | in the alternative format by #.
1152 #       d   | Convert argument as a decimal number.
1153 #       i   | Identical to `d'.
1154 #       o   | Convert argument as an octal number.
1155 #           | Negative numbers will be displayed as a two's complement
1156 #           | prefixed with `..7'.
1157 #       u   | Identical to `d'.
1158 #       x   | Convert argument as a hexadecimal number.
1159 #           | Negative numbers will be displayed as a two's complement
1160 #           | prefixed with `..f' (representing an infinite string of
1161 #           | leading 'ff's).
1162 #       X   | Equivalent to `x', but uses uppercase letters.
1163 # 
1164 #     Field |  Float Format
1165 #     ------+--------------------------------------------------------------
1166 #       e   | Convert floating point argument into exponential notation
1167 #           | with one digit before the decimal point as [-]d.dddddde[+-]dd.
1168 #           | The precision specifies the number of digits after the decimal
1169 #           | point (defaulting to six).
1170 #       E   | Equivalent to `e', but uses an uppercase E to indicate
1171 #           | the exponent.
1172 #       f   | Convert floating point argument as [-]ddd.dddddd,
1173 #           | where the precision specifies the number of digits after
1174 #           | the decimal point.
1175 #       g   | Convert a floating point number using exponential form
1176 #           | if the exponent is less than -4 or greater than or
1177 #           | equal to the precision, or in dd.dddd form otherwise.
1178 #           | The precision specifies the number of significant digits.
1179 #       G   | Equivalent to `g', but use an uppercase `E' in exponent form.
1180 #       a   | Convert floating point argument as [-]0xh.hhhhp[+-]dd,
1181 #           | which is consisted from optional sign, "0x", fraction part
1182 #           | as hexadecimal, "p", and exponential part as decimal.
1183 #       A   | Equivalent to `a', but use uppercase `X' and `P'.
1184 # 
1185 #     Field |  Other Format
1186 #     ------+--------------------------------------------------------------
1187 #       c   | Argument is the numeric code for a single character or
1188 #           | a single character string itself.
1189 #       p   | The valuing of argument.inspect.
1190 #       s   | Argument is a string to be substituted.  If the format
1191 #           | sequence contains a precision, at most that many characters
1192 #           | will be copied.
1193 #       %   | A percent sign itself will be displayed.  No argument taken.
1194 # 
1195 # The flags modifies the behavior of the formats.
1196 # The flag characters are:
1197 # 
1198 #   Flag     | Applies to    | Meaning
1199 #   ---------+---------------+-----------------------------------------
1200 #   space    | bBdiouxX      | Leave a space at the start of
1201 #            | aAeEfgG       | non-negative numbers.
1202 #            | (numeric fmt) | For `o', `x', `X', `b' and `B', use
1203 #            |               | a minus sign with absolute value for
1204 #            |               | negative values.
1205 #   ---------+---------------+-----------------------------------------
1206 #   (digit)$ | all           | Specifies the absolute argument number
1207 #            |               | for this field.  Absolute and relative
1208 #            |               | argument numbers cannot be mixed in a
1209 #            |               | sprintf string.
1210 #   ---------+---------------+-----------------------------------------
1211 #    #       | bBoxX         | Use an alternative format.
1212 #            | aAeEfgG       | For the conversions `o', increase the precision
1213 #            |               | until the first digit will be `0' if
1214 #            |               | it is not formatted as complements.
1215 #            |               | For the conversions `x', `X', `b' and `B'
1216 #            |               | on non-zero, prefix the result with ``0x'',
1217 #            |               | ``0X'', ``0b'' and ``0B'', respectively.
1218 #            |               | For `a', `A', `e', `E', `f', `g', and 'G',
1219 #            |               | force a decimal point to be added,
1220 #            |               | even if no digits follow.
1221 #            |               | For `g' and 'G', do not remove trailing zeros.
1222 #   ---------+---------------+-----------------------------------------
1223 #   +        | bBdiouxX      | Add a leading plus sign to non-negative
1224 #            | aAeEfgG       | numbers.
1225 #            | (numeric fmt) | For `o', `x', `X', `b' and `B', use
1226 #            |               | a minus sign with absolute value for
1227 #            |               | negative values.
1228 #   ---------+---------------+-----------------------------------------
1229 #   -        | all           | Left-justify the result of this conversion.
1230 #   ---------+---------------+-----------------------------------------
1231 #   0 (zero) | bBdiouxX      | Pad with zeros, not spaces.
1232 #            | aAeEfgG       | For `o', `x', `X', `b' and `B', radix-1
1233 #            | (numeric fmt) | is used for negative numbers formatted as
1234 #            |               | complements.
1235 #   ---------+---------------+-----------------------------------------
1236 #   *        | all           | Use the next argument as the field width.
1237 #            |               | If negative, left-justify the result. If the
1238 #            |               | asterisk is followed by a number and a dollar
1239 #            |               | sign, use the indicated argument as the width.
1240 # 
1241 # Examples of flags:
1242 # 
1243 #  # `+' and space flag specifies the sign of non-negative numbers.
1244 #  sprintf("%d", 123)  #=> "123"
1245 #  sprintf("%+d", 123) #=> "+123"
1246 #  sprintf("% d", 123) #=> " 123"
1247 # 
1248 #  # `#' flag for `o' increases number of digits to show `0'.
1249 #  # `+' and space flag changes format of negative numbers.
1250 #  sprintf("%o", 123)   #=> "173"
1251 #  sprintf("%#o", 123)  #=> "0173"
1252 #  sprintf("%+o", -123) #=> "-173"
1253 #  sprintf("%o", -123)  #=> "..7605"
1254 #  sprintf("%#o", -123) #=> "..7605"
1255 # 
1256 #  # `#' flag for `x' add a prefix `0x' for non-zero numbers.
1257 #  # `+' and space flag disables complements for negative numbers.
1258 #  sprintf("%x", 123)   #=> "7b"
1259 #  sprintf("%#x", 123)  #=> "0x7b"
1260 #  sprintf("%+x", -123) #=> "-7b"
1261 #  sprintf("%x", -123)  #=> "..f85"
1262 #  sprintf("%#x", -123) #=> "0x..f85"
1263 #  sprintf("%#x", 0)    #=> "0"
1264 # 
1265 #  # `#' for `X' uses the prefix `0X'.
1266 #  sprintf("%X", 123)  #=> "7B"
1267 #  sprintf("%#X", 123) #=> "0X7B"
1268 # 
1269 #  # `#' flag for `b' add a prefix `0b' for non-zero numbers.
1270 #  # `+' and space flag disables complements for negative numbers.
1271 #  sprintf("%b", 123)   #=> "1111011"
1272 #  sprintf("%#b", 123)  #=> "0b1111011"
1273 #  sprintf("%+b", -123) #=> "-1111011"
1274 #  sprintf("%b", -123)  #=> "..10000101"
1275 #  sprintf("%#b", -123) #=> "0b..10000101"
1276 #  sprintf("%#b", 0)    #=> "0"
1277 # 
1278 #  # `#' for `B' uses the prefix `0B'.
1279 #  sprintf("%B", 123)  #=> "1111011"
1280 #  sprintf("%#B", 123) #=> "0B1111011"
1281 # 
1282 #  # `#' for `e' forces to show the decimal point.
1283 #  sprintf("%.0e", 1)  #=> "1e+00"
1284 #  sprintf("%#.0e", 1) #=> "1.e+00"
1285 # 
1286 #  # `#' for `f' forces to show the decimal point.
1287 #  sprintf("%.0f", 1234)  #=> "1234"
1288 #  sprintf("%#.0f", 1234) #=> "1234."
1289 # 
1290 #  # `#' for `g' forces to show the decimal point.
1291 #  # It also disables stripping lowest zeros.
1292 #  sprintf("%g", 123.4)   #=> "123.4"
1293 #  sprintf("%#g", 123.4)  #=> "123.400"
1294 #  sprintf("%g", 123456)  #=> "123456"
1295 #  sprintf("%#g", 123456) #=> "123456."
1296 # 
1297 # The field width is an optional integer, followed optionally by a
1298 # period and a precision.  The width specifies the minimum number of
1299 # characters that will be written to the result for this field.
1300 # 
1301 # Examples of width:
1302 # 
1303 #  # padding is done by spaces,       width=20
1304 #  # 0 or radix-1.             <------------------>
1305 #  sprintf("%20d", 123)   #=> "                 123"
1306 #  sprintf("%+20d", 123)  #=> "                +123"
1307 #  sprintf("%020d", 123)  #=> "00000000000000000123"
1308 #  sprintf("%+020d", 123) #=> "+0000000000000000123"
1309 #  sprintf("% 020d", 123) #=> " 0000000000000000123"
1310 #  sprintf("%-20d", 123)  #=> "123                 "
1311 #  sprintf("%-+20d", 123) #=> "+123                "
1312 #  sprintf("%- 20d", 123) #=> " 123                "
1313 #  sprintf("%020x", -123) #=> "..ffffffffffffffff85"
1314 # 
1315 # For
1316 # numeric fields, the precision controls the number of decimal places
1317 # displayed.  For string fields, the precision determines the maximum
1318 # number of characters to be copied from the string.  (Thus, the format
1319 # sequence <code>%10.10s</code> will always contribute exactly ten
1320 # characters to the result.)
1321 # 
1322 # Examples of precisions:
1323 # 
1324 #  # precision for `d', 'o', 'x' and 'b' is
1325 #  # minimum number of digits               <------>
1326 #  sprintf("%20.8d", 123)  #=> "            00000123"
1327 #  sprintf("%20.8o", 123)  #=> "            00000173"
1328 #  sprintf("%20.8x", 123)  #=> "            0000007b"
1329 #  sprintf("%20.8b", 123)  #=> "            01111011"
1330 #  sprintf("%20.8d", -123) #=> "           -00000123"
1331 #  sprintf("%20.8o", -123) #=> "            ..777605"
1332 #  sprintf("%20.8x", -123) #=> "            ..ffff85"
1333 #  sprintf("%20.8b", -11)  #=> "            ..110101"
1334 # 
1335 #  # "0x" and "0b" for `#x' and `#b' is not counted for
1336 #  # precision but "0" for `#o' is counted.  <------>
1337 #  sprintf("%#20.8d", 123)  #=> "            00000123"
1338 #  sprintf("%#20.8o", 123)  #=> "            00000173"
1339 #  sprintf("%#20.8x", 123)  #=> "          0x0000007b"
1340 #  sprintf("%#20.8b", 123)  #=> "          0b01111011"
1341 #  sprintf("%#20.8d", -123) #=> "           -00000123"
1342 #  sprintf("%#20.8o", -123) #=> "            ..777605"
1343 #  sprintf("%#20.8x", -123) #=> "          0x..ffff85"
1344 #  sprintf("%#20.8b", -11)  #=> "          0b..110101"
1345 # 
1346 #  # precision for `e' is number of
1347 #  # digits after the decimal point           <------>
1348 #  sprintf("%20.8e", 1234.56789) #=> "      1.23456789e+03"
1349 # 
1350 #  # precision for `f' is number of
1351 #  # digits after the decimal point               <------>
1352 #  sprintf("%20.8f", 1234.56789) #=> "       1234.56789000"
1353 # 
1354 #  # precision for `g' is number of
1355 #  # significant digits                          <------->
1356 #  sprintf("%20.8g", 1234.56789) #=> "           1234.5679"
1357 # 
1358 #  #                                         <------->
1359 #  sprintf("%20.8g", 123456789)  #=> "       1.2345679e+08"
1360 # 
1361 #  # precision for `s' is
1362 #  # maximum number of characters                    <------>
1363 #  sprintf("%20.8s", "string test") #=> "            string t"
1364 # 
1365 # Examples:
1366 # 
1367 #    sprintf("%d %04x", 123, 123)               #=> "123 007b"
1368 #    sprintf("%08b '%4s'", 123, 123)            #=> "01111011 ' 123'"
1369 #    sprintf("%1$*2$s %2$d %1$s", "hello", 8)   #=> "   hello 8 hello"
1370 #    sprintf("%1$*2$s %2$d", "hello", -8)       #=> "hello    -8"
1371 #    sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23)   #=> "+1.23: 1.23:1.23"
1372 #    sprintf("%u", -123)                        #=> "-123"
1373 # 
1374 # For more complex formatting, Ruby supports a reference by name.
1375 # %<name>s style uses format style, but %{name} style doesn't.
1376 # 
1377 # Exapmles:
1378 #   sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 })
1379 #     #=> 1 : 2.000000
1380 #   sprintf("%{foo}f", { :foo => 1 })
1381 #     # => "1f"
1382 def sprintf(format_string  , arguments=0); ''; end
1383 ##
1384 # Returns the string resulting from applying <i>format_string</i> to
1385 # any additional arguments.  Within the format string, any characters
1386 # other than format sequences are copied to the result.
1387 # 
1388 # The syntax of a format sequence is follows.
1389 # 
1390 #   %[flags][width][.precision]type
1391 # 
1392 # A format
1393 # sequence consists of a percent sign, followed by optional flags,
1394 # width, and precision indicators, then terminated with a field type
1395 # character.  The field type controls how the corresponding
1396 # <code>sprintf</code> argument is to be interpreted, while the flags
1397 # modify that interpretation.
1398 # 
1399 # The field type characters are:
1400 # 
1401 #     Field |  Integer Format
1402 #     ------+--------------------------------------------------------------
1403 #       b   | Convert argument as a binary number.
1404 #           | Negative numbers will be displayed as a two's complement
1405 #           | prefixed with `..1'.
1406 #       B   | Equivalent to `b', but uses an uppercase 0B for prefix
1407 #           | in the alternative format by #.
1408 #       d   | Convert argument as a decimal number.
1409 #       i   | Identical to `d'.
1410 #       o   | Convert argument as an octal number.
1411 #           | Negative numbers will be displayed as a two's complement
1412 #           | prefixed with `..7'.
1413 #       u   | Identical to `d'.
1414 #       x   | Convert argument as a hexadecimal number.
1415 #           | Negative numbers will be displayed as a two's complement
1416 #           | prefixed with `..f' (representing an infinite string of
1417 #           | leading 'ff's).
1418 #       X   | Equivalent to `x', but uses uppercase letters.
1419 # 
1420 #     Field |  Float Format
1421 #     ------+--------------------------------------------------------------
1422 #       e   | Convert floating point argument into exponential notation
1423 #           | with one digit before the decimal point as [-]d.dddddde[+-]dd.
1424 #           | The precision specifies the number of digits after the decimal
1425 #           | point (defaulting to six).
1426 #       E   | Equivalent to `e', but uses an uppercase E to indicate
1427 #           | the exponent.
1428 #       f   | Convert floating point argument as [-]ddd.dddddd,
1429 #           | where the precision specifies the number of digits after
1430 #           | the decimal point.
1431 #       g   | Convert a floating point number using exponential form
1432 #           | if the exponent is less than -4 or greater than or
1433 #           | equal to the precision, or in dd.dddd form otherwise.
1434 #           | The precision specifies the number of significant digits.
1435 #       G   | Equivalent to `g', but use an uppercase `E' in exponent form.
1436 #       a   | Convert floating point argument as [-]0xh.hhhhp[+-]dd,
1437 #           | which is consisted from optional sign, "0x", fraction part
1438 #           | as hexadecimal, "p", and exponential part as decimal.
1439 #       A   | Equivalent to `a', but use uppercase `X' and `P'.
1440 # 
1441 #     Field |  Other Format
1442 #     ------+--------------------------------------------------------------
1443 #       c   | Argument is the numeric code for a single character or
1444 #           | a single character string itself.
1445 #       p   | The valuing of argument.inspect.
1446 #       s   | Argument is a string to be substituted.  If the format
1447 #           | sequence contains a precision, at most that many characters
1448 #           | will be copied.
1449 #       %   | A percent sign itself will be displayed.  No argument taken.
1450 # 
1451 # The flags modifies the behavior of the formats.
1452 # The flag characters are:
1453 # 
1454 #   Flag     | Applies to    | Meaning
1455 #   ---------+---------------+-----------------------------------------
1456 #   space    | bBdiouxX      | Leave a space at the start of
1457 #            | aAeEfgG       | non-negative numbers.
1458 #            | (numeric fmt) | For `o', `x', `X', `b' and `B', use
1459 #            |               | a minus sign with absolute value for
1460 #            |               | negative values.
1461 #   ---------+---------------+-----------------------------------------
1462 #   (digit)$ | all           | Specifies the absolute argument number
1463 #            |               | for this field.  Absolute and relative
1464 #            |               | argument numbers cannot be mixed in a
1465 #            |               | sprintf string.
1466 #   ---------+---------------+-----------------------------------------
1467 #    #       | bBoxX         | Use an alternative format.
1468 #            | aAeEfgG       | For the conversions `o', increase the precision
1469 #            |               | until the first digit will be `0' if
1470 #            |               | it is not formatted as complements.
1471 #            |               | For the conversions `x', `X', `b' and `B'
1472 #            |               | on non-zero, prefix the result with ``0x'',
1473 #            |               | ``0X'', ``0b'' and ``0B'', respectively.
1474 #            |               | For `a', `A', `e', `E', `f', `g', and 'G',
1475 #            |               | force a decimal point to be added,
1476 #            |               | even if no digits follow.
1477 #            |               | For `g' and 'G', do not remove trailing zeros.
1478 #   ---------+---------------+-----------------------------------------
1479 #   +        | bBdiouxX      | Add a leading plus sign to non-negative
1480 #            | aAeEfgG       | numbers.
1481 #            | (numeric fmt) | For `o', `x', `X', `b' and `B', use
1482 #            |               | a minus sign with absolute value for
1483 #            |               | negative values.
1484 #   ---------+---------------+-----------------------------------------
1485 #   -        | all           | Left-justify the result of this conversion.
1486 #   ---------+---------------+-----------------------------------------
1487 #   0 (zero) | bBdiouxX      | Pad with zeros, not spaces.
1488 #            | aAeEfgG       | For `o', `x', `X', `b' and `B', radix-1
1489 #            | (numeric fmt) | is used for negative numbers formatted as
1490 #            |               | complements.
1491 #   ---------+---------------+-----------------------------------------
1492 #   *        | all           | Use the next argument as the field width.
1493 #            |               | If negative, left-justify the result. If the
1494 #            |               | asterisk is followed by a number and a dollar
1495 #            |               | sign, use the indicated argument as the width.
1496 # 
1497 # Examples of flags:
1498 # 
1499 #  # `+' and space flag specifies the sign of non-negative numbers.
1500 #  sprintf("%d", 123)  #=> "123"
1501 #  sprintf("%+d", 123) #=> "+123"
1502 #  sprintf("% d", 123) #=> " 123"
1503 # 
1504 #  # `#' flag for `o' increases number of digits to show `0'.
1505 #  # `+' and space flag changes format of negative numbers.
1506 #  sprintf("%o", 123)   #=> "173"
1507 #  sprintf("%#o", 123)  #=> "0173"
1508 #  sprintf("%+o", -123) #=> "-173"
1509 #  sprintf("%o", -123)  #=> "..7605"
1510 #  sprintf("%#o", -123) #=> "..7605"
1511 # 
1512 #  # `#' flag for `x' add a prefix `0x' for non-zero numbers.
1513 #  # `+' and space flag disables complements for negative numbers.
1514 #  sprintf("%x", 123)   #=> "7b"
1515 #  sprintf("%#x", 123)  #=> "0x7b"
1516 #  sprintf("%+x", -123) #=> "-7b"
1517 #  sprintf("%x", -123)  #=> "..f85"
1518 #  sprintf("%#x", -123) #=> "0x..f85"
1519 #  sprintf("%#x", 0)    #=> "0"
1520 # 
1521 #  # `#' for `X' uses the prefix `0X'.
1522 #  sprintf("%X", 123)  #=> "7B"
1523 #  sprintf("%#X", 123) #=> "0X7B"
1524 # 
1525 #  # `#' flag for `b' add a prefix `0b' for non-zero numbers.
1526 #  # `+' and space flag disables complements for negative numbers.
1527 #  sprintf("%b", 123)   #=> "1111011"
1528 #  sprintf("%#b", 123)  #=> "0b1111011"
1529 #  sprintf("%+b", -123) #=> "-1111011"
1530 #  sprintf("%b", -123)  #=> "..10000101"
1531 #  sprintf("%#b", -123) #=> "0b..10000101"
1532 #  sprintf("%#b", 0)    #=> "0"
1533 # 
1534 #  # `#' for `B' uses the prefix `0B'.
1535 #  sprintf("%B", 123)  #=> "1111011"
1536 #  sprintf("%#B", 123) #=> "0B1111011"
1537 # 
1538 #  # `#' for `e' forces to show the decimal point.
1539 #  sprintf("%.0e", 1)  #=> "1e+00"
1540 #  sprintf("%#.0e", 1) #=> "1.e+00"
1541 # 
1542 #  # `#' for `f' forces to show the decimal point.
1543 #  sprintf("%.0f", 1234)  #=> "1234"
1544 #  sprintf("%#.0f", 1234) #=> "1234."
1545 # 
1546 #  # `#' for `g' forces to show the decimal point.
1547 #  # It also disables stripping lowest zeros.
1548 #  sprintf("%g", 123.4)   #=> "123.4"
1549 #  sprintf("%#g", 123.4)  #=> "123.400"
1550 #  sprintf("%g", 123456)  #=> "123456"
1551 #  sprintf("%#g", 123456) #=> "123456."
1552 # 
1553 # The field width is an optional integer, followed optionally by a
1554 # period and a precision.  The width specifies the minimum number of
1555 # characters that will be written to the result for this field.
1556 # 
1557 # Examples of width:
1558 # 
1559 #  # padding is done by spaces,       width=20
1560 #  # 0 or radix-1.             <------------------>
1561 #  sprintf("%20d", 123)   #=> "                 123"
1562 #  sprintf("%+20d", 123)  #=> "                +123"
1563 #  sprintf("%020d", 123)  #=> "00000000000000000123"
1564 #  sprintf("%+020d", 123) #=> "+0000000000000000123"
1565 #  sprintf("% 020d", 123) #=> " 0000000000000000123"
1566 #  sprintf("%-20d", 123)  #=> "123                 "
1567 #  sprintf("%-+20d", 123) #=> "+123                "
1568 #  sprintf("%- 20d", 123) #=> " 123                "
1569 #  sprintf("%020x", -123) #=> "..ffffffffffffffff85"
1570 # 
1571 # For
1572 # numeric fields, the precision controls the number of decimal places
1573 # displayed.  For string fields, the precision determines the maximum
1574 # number of characters to be copied from the string.  (Thus, the format
1575 # sequence <code>%10.10s</code> will always contribute exactly ten
1576 # characters to the result.)
1577 # 
1578 # Examples of precisions:
1579 # 
1580 #  # precision for `d', 'o', 'x' and 'b' is
1581 #  # minimum number of digits               <------>
1582 #  sprintf("%20.8d", 123)  #=> "            00000123"
1583 #  sprintf("%20.8o", 123)  #=> "            00000173"
1584 #  sprintf("%20.8x", 123)  #=> "            0000007b"
1585 #  sprintf("%20.8b", 123)  #=> "            01111011"
1586 #  sprintf("%20.8d", -123) #=> "           -00000123"
1587 #  sprintf("%20.8o", -123) #=> "            ..777605"
1588 #  sprintf("%20.8x", -123) #=> "            ..ffff85"
1589 #  sprintf("%20.8b", -11)  #=> "            ..110101"
1590 # 
1591 #  # "0x" and "0b" for `#x' and `#b' is not counted for
1592 #  # precision but "0" for `#o' is counted.  <------>
1593 #  sprintf("%#20.8d", 123)  #=> "            00000123"
1594 #  sprintf("%#20.8o", 123)  #=> "            00000173"
1595 #  sprintf("%#20.8x", 123)  #=> "          0x0000007b"
1596 #  sprintf("%#20.8b", 123)  #=> "          0b01111011"
1597 #  sprintf("%#20.8d", -123) #=> "           -00000123"
1598 #  sprintf("%#20.8o", -123) #=> "            ..777605"
1599 #  sprintf("%#20.8x", -123) #=> "          0x..ffff85"
1600 #  sprintf("%#20.8b", -11)  #=> "          0b..110101"
1601 # 
1602 #  # precision for `e' is number of
1603 #  # digits after the decimal point           <------>
1604 #  sprintf("%20.8e", 1234.56789) #=> "      1.23456789e+03"
1605 # 
1606 #  # precision for `f' is number of
1607 #  # digits after the decimal point               <------>
1608 #  sprintf("%20.8f", 1234.56789) #=> "       1234.56789000"
1609 # 
1610 #  # precision for `g' is number of
1611 #  # significant digits                          <------->
1612 #  sprintf("%20.8g", 1234.56789) #=> "           1234.5679"
1613 # 
1614 #  #                                         <------->
1615 #  sprintf("%20.8g", 123456789)  #=> "       1.2345679e+08"
1616 # 
1617 #  # precision for `s' is
1618 #  # maximum number of characters                    <------>
1619 #  sprintf("%20.8s", "string test") #=> "            string t"
1620 # 
1621 # Examples:
1622 # 
1623 #    sprintf("%d %04x", 123, 123)               #=> "123 007b"
1624 #    sprintf("%08b '%4s'", 123, 123)            #=> "01111011 ' 123'"
1625 #    sprintf("%1$*2$s %2$d %1$s", "hello", 8)   #=> "   hello 8 hello"
1626 #    sprintf("%1$*2$s %2$d", "hello", -8)       #=> "hello    -8"
1627 #    sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23)   #=> "+1.23: 1.23:1.23"
1628 #    sprintf("%u", -123)                        #=> "-123"
1629 # 
1630 # For more complex formatting, Ruby supports a reference by name.
1631 # %<name>s style uses format style, but %{name} style doesn't.
1632 # 
1633 # Exapmles:
1634 #   sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 })
1635 #     #=> 1 : 2.000000
1636 #   sprintf("%{foo}f", { :foo => 1 })
1637 #     # => "1f"
1638 def format(format_string  , arguments=0); ''; end
1639 ##
1640 # Converts <i>arg</i> to a <code>Fixnum</code> or <code>Bignum</code>.
1641 # Numeric types are converted directly (with floating point numbers
1642 # being truncated).    <i>base</i> (0, or between 2 and 36) is a base for
1643 # integer string representation.  If <i>arg</i> is a <code>String</code>,
1644 # when <i>base</i> is omitted or equals to zero, radix indicators
1645 # (<code>0</code>, <code>0b</code>, and <code>0x</code>) are honored.
1646 # In any case, strings should be strictly conformed to numeric
1647 # representation. This behavior is different from that of
1648 # <code>String#to_i</code>.  Non string values will be converted using
1649 # <code>to_int</code>, and <code>to_i</code>.
1650 # 
1651 #    Integer(123.999)    #=> 123
1652 #    Integer("0x1a")     #=> 26
1653 #    Integer(Time.new)   #=> 1204973019
1654 #    Integer("0930", 10) #=> 930
1655 #    Integer("111", 2)   #=> 7
1656 def Integer(arg,base=0); 0; end
1657 ##
1658 # Returns <i>arg</i> converted to a float. Numeric types are converted
1659 # directly, the rest are converted using <i>arg</i>.to_f. As of Ruby
1660 # 1.8, converting <code>nil</code> generates a <code>TypeError</code>.
1661 # 
1662 #    Float(1)           #=> 1.0
1663 #    Float("123.456")   #=> 123.456
1664 def Float(arg); 0.0; end
1665 ##
1666 # Converts <i>arg</i> to a <code>String</code> by calling its
1667 # <code>to_s</code> method.
1668 # 
1669 #    String(self)        #=> "main"
1670 #    String(self.class)  #=> "Object"
1671 #    String(123456)      #=> "123456"
1672 def String(arg); ''; end
1673 ##
1674 # Returns +arg+ as an Array.
1675 # 
1676 # First tries to call Array#to_ary on +arg+, then Array#to_a.
1677 # 
1678 #    Array(1..5)   #=> [1, 2, 3, 4, 5]
1679 def Array(arg); []; end
1680 ##
1681 # Converts <i>arg</i> to a <code>Hash</code> by calling
1682 # <i>arg</i><code>.to_hash</code>. Returns an empty <code>Hash</code> when
1683 # <i>arg</i> is <tt>nil</tt> or <tt>[]</tt>.
1684 # 
1685 #    Hash([])          #=> {}
1686 #    Hash(nil)         #=> nil
1687 #    Hash(key: :value) #=> {:key => :value}
1688 #    Hash([1, 2, 3])   #=> TypeError
1689 def Hash(arg); {}; end
1690 ##
1691 # Generates a Continuation object, which it passes to
1692 # the associated block. You need to <code>require
1693 # 'continuation'</code> before using this method. Performing a
1694 # <em>cont</em><code>.call</code> will cause the #callcc
1695 # to return (as will falling through the end of the block). The
1696 # value returned by the #callcc is the value of the
1697 # block, or the value passed to <em>cont</em><code>.call</code>. See
1698 # class Continuation for more details. Also see
1699 # Kernel#throw for an alternative mechanism for
1700 # unwinding a call stack.
1701 def callcc(&block); Object.new; end
1702 ##
1703 # Returns x+i*y;
1704 # 
1705 #    Complex(1, 2)    #=> (1+2i)
1706 #    Complex('1+2i')  #=> (1+2i)
1707 # 
1708 # Syntax of string form:
1709 # 
1710 #   string form = extra spaces , complex , extra spaces ;
1711 #   complex = real part | [ sign ] , imaginary part
1712 #           | real part , sign , imaginary part
1713 #           | rational , "@" , rational ;
1714 #   real part = rational ;
1715 #   imaginary part = imaginary unit | unsigned rational , imaginary unit ;
1716 #   rational = [ sign ] , unsigned rational ;
1717 #   unsigned rational = numerator | numerator , "/" , denominator ;
1718 #   numerator = integer part | fractional part | integer part , fractional part ;
1719 #   denominator = digits ;
1720 #   integer part = digits ;
1721 #   fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
1722 #   imaginary unit = "i" | "I" | "j" | "J" ;
1723 #   sign = "-" | "+" ;
1724 #   digits = digit , { digit | "_" , digit };
1725 #   digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
1726 #   extra spaces = ? \s* ? ;
1727 # 
1728 # See String#to_c.
1729 def Complex(x, y=0); 0; end
1730 ##
1731 #  Calls the operating system function identified by _num_ and
1732 #  returns the result of the function or raises SystemCallError if
1733 #  it failed.
1734 # 
1735 #  Arguments for the function can follow _num_. They must be either
1736 #  +String+ objects or +Integer+ objects. A +String+ object is passed
1737 #  as a pointer to the byte sequence. An +Integer+ object is passed
1738 #  as an integer whose bit size is same as a pointer.
1739 #  Up to nine parameters may be passed (14 on the Atari-ST).
1740 # 
1741 #  The function identified by _num_ is system
1742 #  dependent. On some Unix systems, the numbers may be obtained from a
1743 #  header file called <code>syscall.h</code>.
1744 # 
1745 #     syscall 4, 1, "hello\n", 6   # '4' is write(2) on our box
1746 # 
1747 #  <em>produces:</em>
1748 # 
1749 #     hello
1750 # 
1751 #  Calling +syscall+ on a platform which does not have any way to
1752 #  an arbitrary system function just fails with NotImplementedError.
1753 # 
1754 # Note::
1755 #   +syscall+ is essentially unsafe and unportable. Feel free to shoot your foot.
1756 #   DL (Fiddle) library is preferred for safer and a bit more portable programming.
1757 def syscall(num , args=0); 0; end
1758 ##
1759 # Creates an IO object connected to the given stream, file, or subprocess.
1760 # 
1761 # If +path+ does not start with a pipe character (<code>|</code>), treat it
1762 # as the name of a file to open using the specified mode (defaulting to
1763 # "r").
1764 # 
1765 # The +mode+ is either a string or an integer.  If it is an integer, it
1766 # must be bitwise-or of open(2) flags, such as File::RDWR or File::EXCL.  If
1767 # it is a string, it is either "fmode", "fmode:ext_enc", or
1768 # "fmode:ext_enc:int_enc".
1769 # 
1770 # See the documentation of IO.new for full documentation of the +mode+ string
1771 # directives.
1772 # 
1773 # If a file is being created, its initial permissions may be set using the
1774 # +perm+ parameter.  See File.new and the open(2) and chmod(2) man pages for
1775 # a description of permissions.
1776 # 
1777 # If a block is specified, it will be invoked with the IO object as a
1778 # parameter, and the IO will be automatically closed when the block
1779 # terminates.  The call returns the value of the block.
1780 # 
1781 # If +path+ starts with a pipe character (<code>"|"</code>), a subprocess is
1782 # created, connected to the caller by a pair of pipes.  The returned IO
1783 # object may be used to write to the standard input and read from the
1784 # standard output of this subprocess.
1785 # 
1786 # If the command following the pipe is a single minus sign
1787 # (<code>"|-"</code>), Ruby forks, and this subprocess is connected to the
1788 # parent.  If the command is not <code>"-"</code>, the subprocess runs the
1789 # command.
1790 # 
1791 # When the subprocess is ruby (opened via <code>"|-"</code>), the +open+
1792 # call returns +nil+.  If a block is associated with the open call, that
1793 # block will run twice --- once in the parent and once in the child.
1794 # 
1795 # The block parameter will be an IO object in the parent and +nil+ in the
1796 # child. The parent's +IO+ object will be connected to the child's $stdin
1797 # and $stdout.  The subprocess will be terminated at the end of the block.
1798 # 
1799 # === Examples
1800 # 
1801 # Reading from "testfile":
1802 # 
1803 #    open("testfile") do |f|
1804 #      print f.gets
1805 #    end
1806 # 
1807 # Produces:
1808 # 
1809 #    This is line one
1810 # 
1811 # Open a subprocess and read its output:
1812 # 
1813 #    cmd = open("|date")
1814 #    print cmd.gets
1815 #    cmd.close
1816 # 
1817 # Produces:
1818 # 
1819 #    Wed Apr  9 08:56:31 CDT 2003
1820 # 
1821 # Open a subprocess running the same Ruby program:
1822 # 
1823 #    f = open("|-", "w+")
1824 #    if f == nil
1825 #      puts "in Child"
1826 #      exit
1827 #    else
1828 #      puts "Got: #{f.gets}"
1829 #    end
1830 # 
1831 # Produces:
1832 # 
1833 #    Got: in Child
1834 # 
1835 # Open a subprocess using a block to receive the IO object:
1836 # 
1837 #    open "|-" do |f|
1838 #      if f then
1839 #        # parent process
1840 #        puts "Got: #{f.gets}"
1841 #      else
1842 #        # child process
1843 #        puts "in Child"
1844 #      end
1845 #    end
1846 # 
1847 # Produces:
1848 # 
1849 #    Got: in Child
1850 def open(path , mode=0, perm=0, opt=0); Object.new; end
1851 ##
1852 # Equivalent to:
1853 #    io.write(sprintf(string, obj, ...)
1854 # or
1855 #    $stdout.write(sprintf(string, obj, ...)
1856 def printf(io, string , obj=0); end
1857 ##
1858 # Prints each object in turn to <code>$stdout</code>. If the output
1859 # field separator (<code>$,</code>) is not +nil+, its
1860 # contents will appear between each field. If the output record
1861 # separator (<code>$\\</code>) is not +nil+, it will be
1862 # appended to the output. If no arguments are given, prints
1863 # <code>$_</code>. Objects that aren't strings will be converted by
1864 # calling their <code>to_s</code> method.
1865 # 
1866 #    print "cat", [1,2,3], 99, "\n"
1867 #    $, = ", "
1868 #    $\ = "\n"
1869 #    print "cat", [1,2,3], 99
1870 # 
1871 # <em>produces:</em>
1872 # 
1873 #    cat12399
1874 #    cat, 1, 2, 3, 99
1875 def print(); end
1876 ##
1877 #  Equivalent to:
1878 # 
1879 #    $stdout.putc(int)
1880 # 
1881 # Refer to the documentation for IO#putc for important information regarding
1882 # multi-byte characters.
1883 def putc(int); 0; end
1884 ##
1885 # Equivalent to
1886 # 
1887 #     $stdout.puts(obj, ...)
1888 def puts(); end
1889 ##
1890 # Returns (and assigns to <code>$_</code>) the next line from the list
1891 # of files in +ARGV+ (or <code>$*</code>), or from standard input if
1892 # no files are present on the command line. Returns +nil+ at end of
1893 # file. The optional argument specifies the record separator. The
1894 # separator is included with the contents of each record. A separator
1895 # of +nil+ reads the entire contents, and a zero-length separator
1896 # reads the input one paragraph at a time, where paragraphs are
1897 # divided by two consecutive newlines.  If the first argument is an
1898 # integer, or optional second argument is given, the returning string
1899 # would not be longer than the given value in bytes.  If multiple
1900 # filenames are present in +ARGV+, +gets(nil)+ will read the contents
1901 # one file at a time.
1902 # 
1903 #    ARGV << "testfile"
1904 #    print while gets
1905 # 
1906 # <em>produces:</em>
1907 # 
1908 #    This is line one
1909 #    This is line two
1910 #    This is line three
1911 #    And so on...
1912 # 
1913 # The style of programming using <code>$_</code> as an implicit
1914 # parameter is gradually losing favor in the Ruby community.
1915 def gets(sep=$/); '' || nil; end
1916 ##
1917 # Equivalent to <code>Kernel::gets</code>, except
1918 # +readline+ raises +EOFError+ at end of file.
1919 def readline(sep=$/); ''; end
1920 ##
1921 # Calls select(2) system call.
1922 # It monitors given arrays of <code>IO</code> objects, waits one or more
1923 # of <code>IO</code> objects ready for reading, are ready for writing,
1924 # and have pending exceptions respectively, and returns an array that
1925 # contains arrays of those IO objects.  It will return <code>nil</code>
1926 # if optional <i>timeout</i> value is given and no <code>IO</code> object
1927 # is ready in <i>timeout</i> seconds.
1928 # 
1929 # === Parameters
1930 # read_array:: an array of <code>IO</code> objects that wait until ready for read
1931 # write_array:: an array of <code>IO</code> objects that wait until ready for write
1932 # error_array:: an array of <code>IO</code> objects that wait for exceptions
1933 # timeout:: a numeric value in second
1934 # 
1935 # === Example
1936 # 
1937 #     rp, wp = IO.pipe
1938 #     mesg = "ping "
1939 #     100.times {
1940 #       rs, ws, = IO.select([rp], [wp])
1941 #       if r = rs[0]
1942 #         ret = r.read(5)
1943 #         print ret
1944 #         case ret
1945 #         when /ping/
1946 #           mesg = "pong\n"
1947 #         when /pong/
1948 #           mesg = "ping "
1949 #         end
1950 #       end
1951 #       if w = ws[0]
1952 #         w.write(mesg)
1953 #       end
1954 #     }
1955 # 
1956 # <em>produces:</em>
1957 # 
1958 #     ping pong
1959 #     ping pong
1960 #     ping pong
1961 #     (snipped)
1962 #     ping
1963 def select(read_arra); [] || nil; end
1964 ##
1965 # Returns an array containing the lines returned by calling
1966 # <code>Kernel.gets(<i>sep</i>)</code> until the end of file.
1967 def readlines(sep=$/); []; end
1968 ##
1969 # Returns the standard output of running _cmd_ in a subshell.
1970 # The built-in syntax <code>%x{...}</code> uses
1971 # this method. Sets <code>$?</code> to the process status.
1972 # 
1973 #    `date`                   #=> "Wed Apr  9 08:56:30 CDT 2003\n"
1974 #    `ls testdir`.split[1]    #=> "main.rb"
1975 #    `echo oops && exit 99`   #=> "oops\n"
1976 #    $?.exitstatus            #=> 99
1977 def `; ''; end
1978 ##
1979 # For each object, directly writes _obj_.+inspect+ followed by a
1980 # newline to the program's standard output.
1981 # 
1982 #    S = Struct.new(:name, :state)
1983 #    s = S['dave', 'TX']
1984 #    p s
1985 # 
1986 # <em>produces:</em>
1987 # 
1988 #    #<S name="dave", state="TX">
1989 def p(obj); end
1990 end
1991 
1992 ##
1993 # Ruby exception objects are subclasses of <code>Exception</code>.
1994 # However, operating systems typically report errors using plain
1995 # integers. Module <code>Errno</code> is created dynamically to map
1996 # these operating system errors to Ruby classes, with each error
1997 # number generating its own subclass of <code>SystemCallError</code>.
1998 # As the subclass is created in module <code>Errno</code>, its name
1999 # will start <code>Errno::</code>.
2000 # 
2001 # The names of the <code>Errno::</code> classes depend on
2002 # the environment in which Ruby runs. On a typical Unix or Windows
2003 # platform, there are <code>Errno</code> classes such as
2004 # <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
2005 # <code>Errno::EINTR</code>, and so on.
2006 # 
2007 # The integer operating system error number corresponding to a
2008 # particular error is available as the class constant
2009 # <code>Errno::</code><em>error</em><code>::Errno</code>.
2010 # 
2011 #    Errno::EACCES::Errno   #=> 13
2012 #    Errno::EAGAIN::Errno   #=> 11
2013 #    Errno::EINTR::Errno    #=> 4
2014 # 
2015 # The full list of operating system errors on your particular platform
2016 # are available as the constants of <code>Errno</code>.
2017 # 
2018 #    Errno.constants   #=> :E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, ...
2019 module Errno
2020 end
2021 
2022 ##
2023 # The <code>Math</code> module contains module functions for basic
2024 # trigonometric and transcendental functions. See class
2025 # <code>Float</code> for a list of constants that
2026 # define Ruby's floating point accuracy.
2027 module Math
2028 ##
2029 # Raised when a mathematical function is evaluated outside of its
2030 # domain of definition.
2031 # 
2032 # For example, since +cos+ returns values in the range -1..1,
2033 # its inverse function +acos+ is only defined on that interval:
2034 # 
2035 #    Math.acos(42)
2036 # 
2037 # <em>produces:</em>
2038 # 
2039 #    Math::DomainError: Numerical argument is out of domain - "acos"
2040 class DomainError < StandardError
2041 end
2042 
2043 ##
2044 # Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
2045 # -PI..PI.
2046 # 
2047 #   Math.atan2(-0.0, -1.0) #=> -3.141592653589793
2048 #   Math.atan2(-1.0, -1.0) #=> -2.356194490192345
2049 #   Math.atan2(-1.0, 0.0)  #=> -1.5707963267948966
2050 #   Math.atan2(-1.0, 1.0)  #=> -0.7853981633974483
2051 #   Math.atan2(-0.0, 1.0)  #=> -0.0
2052 #   Math.atan2(0.0, 1.0)   #=> 0.0
2053 #   Math.atan2(1.0, 1.0)   #=> 0.7853981633974483
2054 #   Math.atan2(1.0, 0.0)   #=> 1.5707963267948966
2055 #   Math.atan2(1.0, -1.0)  #=> 2.356194490192345
2056 #   Math.atan2(0.0, -1.0)  #=> 3.141592653589793
2057 def self.atan2(y, x); 0.0; end
2058 ##
2059 # Computes the cosine of <i>x</i> (expressed in radians). Returns
2060 # -1..1.
2061 def self.cos(x); 0.0; end
2062 ##
2063 # Computes the sine of <i>x</i> (expressed in radians). Returns
2064 # -1..1.
2065 def self.sin(x); 0.0; end
2066 ##
2067 # Returns the tangent of <i>x</i> (expressed in radians).
2068 def self.tan(x); 0.0; end
2069 ##
2070 # Computes the arc cosine of <i>x</i>. Returns 0..PI.
2071 def self.acos(x); 0.0; end
2072 ##
2073 # Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
2074 def self.asin(x); 0.0; end
2075 ##
2076 # Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
2077 def self.atan(x); 0.0; end
2078 ##
2079 # Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
2080 def self.cosh(x); 0.0; end
2081 ##
2082 # Computes the hyperbolic sine of <i>x</i> (expressed in
2083 # radians).
2084 def self.sinh(x); 0.0; end
2085 ##
2086 # Computes the hyperbolic tangent of <i>x</i> (expressed in
2087 # radians).
2088 def self.tanh(); 0.0; end
2089 ##
2090 # Computes the inverse hyperbolic cosine of <i>x</i>.
2091 def self.acosh(x); 0.0; end
2092 ##
2093 # Computes the inverse hyperbolic sine of <i>x</i>.
2094 def self.asinh(x); 0.0; end
2095 ##
2096 # Computes the inverse hyperbolic tangent of <i>x</i>.
2097 def self.atanh(x); 0.0; end
2098 ##
2099 # Returns e**x.
2100 # 
2101 #   Math.exp(0)       #=> 1.0
2102 #   Math.exp(1)       #=> 2.718281828459045
2103 #   Math.exp(1.5)     #=> 4.4816890703380645
2104 def self.exp(x); 0.0; end
2105 ##
2106 # Returns the natural logarithm of <i>numeric</i>.
2107 # If additional second argument is given, it will be the base
2108 # of logarithm.
2109 # 
2110 #   Math.log(1)          #=> 0.0
2111 #   Math.log(Math::E)    #=> 1.0
2112 #   Math.log(Math::E**3) #=> 3.0
2113 #   Math.log(12,3)       #=> 2.2618595071429146
2114 def self.log(numeric); 0.0; end
2115 ##
2116 # Returns the base 2 logarithm of <i>numeric</i>.
2117 # 
2118 #   Math.log2(1)      #=> 0.0
2119 #   Math.log2(2)      #=> 1.0
2120 #   Math.log2(32768)  #=> 15.0
2121 #   Math.log2(65536)  #=> 16.0
2122 def self.log2(numeric); 0.0; end
2123 ##
2124 # Returns the base 10 logarithm of <i>numeric</i>.
2125 # 
2126 #   Math.log10(1)       #=> 0.0
2127 #   Math.log10(10)      #=> 1.0
2128 #   Math.log10(10**100) #=> 100.0
2129 def self.log10(numeric); 0.0; end
2130 ##
2131 # Returns the non-negative square root of <i>numeric</i>.
2132 # 
2133 #   0.upto(10) {|x|
2134 #     p [x, Math.sqrt(x), Math.sqrt(x)**2]
2135 #   }
2136 #   #=>
2137 #   [0, 0.0, 0.0]
2138 #   [1, 1.0, 1.0]
2139 #   [2, 1.4142135623731, 2.0]
2140 #   [3, 1.73205080756888, 3.0]
2141 #   [4, 2.0, 4.0]
2142 #   [5, 2.23606797749979, 5.0]
2143 #   [6, 2.44948974278318, 6.0]
2144 #   [7, 2.64575131106459, 7.0]
2145 #   [8, 2.82842712474619, 8.0]
2146 #   [9, 3.0, 9.0]
2147 #   [10, 3.16227766016838, 10.0]
2148 def self.sqrt(numeric); 0.0; end
2149 ##
2150 # Returns the cube root of <i>numeric</i>.
2151 # 
2152 #   -9.upto(9) {|x|
2153 #     p [x, Math.cbrt(x), Math.cbrt(x)**3]
2154 #   }
2155 #   #=>
2156 #   [-9, -2.0800838230519, -9.0]
2157 #   [-8, -2.0, -8.0]
2158 #   [-7, -1.91293118277239, -7.0]
2159 #   [-6, -1.81712059283214, -6.0]
2160 #   [-5, -1.7099759466767, -5.0]
2161 #   [-4, -1.5874010519682, -4.0]
2162 #   [-3, -1.44224957030741, -3.0]
2163 #   [-2, -1.25992104989487, -2.0]
2164 #   [-1, -1.0, -1.0]
2165 #   [0, 0.0, 0.0]
2166 #   [1, 1.0, 1.0]
2167 #   [2, 1.25992104989487, 2.0]
2168 #   [3, 1.44224957030741, 3.0]
2169 #   [4, 1.5874010519682, 4.0]
2170 #   [5, 1.7099759466767, 5.0]
2171 #   [6, 1.81712059283214, 6.0]
2172 #   [7, 1.91293118277239, 7.0]
2173 #   [8, 2.0, 8.0]
2174 #   [9, 2.0800838230519, 9.0]
2175 def self.cbrt(numeric); 0.0; end
2176 ##
2177 # Returns a two-element array containing the normalized fraction (a
2178 # <code>Float</code>) and exponent (a <code>Fixnum</code>) of
2179 # <i>numeric</i>.
2180 # 
2181 #    fraction, exponent = Math.frexp(1234)   #=> [0.6025390625, 11]
2182 #    fraction * 2**exponent                  #=> 1234.0
2183 def self.frexp(numeric); []; end
2184 ##
2185 # Returns the value of <i>flt</i>*(2**<i>int</i>).
2186 # 
2187 #    fraction, exponent = Math.frexp(1234)
2188 #    Math.ldexp(fraction, exponent)   #=> 1234.0
2189 def self.ldexp(flt, int); 0.0; end
2190 ##
2191 # Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
2192 # with sides <i>x</i> and <i>y</i>.
2193 # 
2194 #    Math.hypot(3, 4)   #=> 5.0
2195 def self.hypot(x, y); 0.0; end
2196 ##
2197 # Calculates the error function of x.
2198 def self.erf(x); 0.0; end
2199 ##
2200 # Calculates the complementary error function of x.
2201 def self.erfc(x); 0.0; end
2202 ##
2203 # Calculates the gamma function of x.
2204 # 
2205 # Note that gamma(n) is same as fact(n-1) for integer n > 0.
2206 # However gamma(n) returns float and can be an approximation.
2207 # 
2208 #  def fact(n) (1..n).inject(1) {|r,i| r*i } end
2209 #  1.upto(26) {|i| p [i, Math.gamma(i), fact(i-1)] }
2210 #  #=> [1, 1.0, 1]
2211 #  #   [2, 1.0, 1]
2212 #  #   [3, 2.0, 2]
2213 #  #   [4, 6.0, 6]
2214 #  #   [5, 24.0, 24]
2215 #  #   [6, 120.0, 120]
2216 #  #   [7, 720.0, 720]
2217 #  #   [8, 5040.0, 5040]
2218 #  #   [9, 40320.0, 40320]
2219 #  #   [10, 362880.0, 362880]
2220 #  #   [11, 3628800.0, 3628800]
2221 #  #   [12, 39916800.0, 39916800]
2222 #  #   [13, 479001600.0, 479001600]
2223 #  #   [14, 6227020800.0, 6227020800]
2224 #  #   [15, 87178291200.0, 87178291200]
2225 #  #   [16, 1307674368000.0, 1307674368000]
2226 #  #   [17, 20922789888000.0, 20922789888000]
2227 #  #   [18, 355687428096000.0, 355687428096000]
2228 #  #   [19, 6.402373705728e+15, 6402373705728000]
2229 #  #   [20, 1.21645100408832e+17, 121645100408832000]
2230 #  #   [21, 2.43290200817664e+18, 2432902008176640000]
2231 #  #   [22, 5.109094217170944e+19, 51090942171709440000]
2232 #  #   [23, 1.1240007277776077e+21, 1124000727777607680000]
2233 #  #   [24, 2.5852016738885062e+22, 25852016738884976640000]
2234 #  #   [25, 6.204484017332391e+23, 620448401733239439360000]
2235 #  #   [26, 1.5511210043330954e+25, 15511210043330985984000000]
2236 def self.gamma(x); 0.0; end
2237 ##
2238 # Calculates the logarithmic gamma of x and
2239 # the sign of gamma of x.
2240 # 
2241 # Math.lgamma(x) is same as
2242 #  [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
2243 # but avoid overflow by Math.gamma(x) for large x.
2244 def self.lgamma(x); [0.0, 0]; end
2245 end
2246 
2247 ##
2248 # The GC module provides an interface to Ruby's mark and
2249 # sweep garbage collection mechanism.
2250 # 
2251 # Some of the underlying methods are also available via the ObjectSpace
2252 # module.
2253 # 
2254 # You may obtain information about the operation of the GC through
2255 # GC::Profiler.
2256 module GC
2257 ##
2258 # Initiates garbage collection, unless manually disabled.
2259 def self.start; end
2260 ##
2261 # Initiates garbage collection, unless manually disabled.
2262 def self.garbage_collect; end
2263 ##
2264 # Enables garbage collection, returning +true+ if garbage
2265 # collection was previously disabled.
2266 # 
2267 #    GC.disable   #=> false
2268 #    GC.enable    #=> true
2269 #    GC.enable    #=> false
2270 def self.enable; true || false; end
2271 ##
2272 # Disables garbage collection, returning +true+ if garbage
2273 # collection was already disabled.
2274 # 
2275 #    GC.disable   #=> false
2276 #    GC.disable   #=> true
2277 def self.disable; true || false; end
2278 ##
2279 # Returns current status of GC stress mode.
2280 def self.stress; true || false; end
2281 ##
2282 # Updates the GC stress mode.
2283 # 
2284 # When stress mode is enabled, the GC is invoked at every GC opportunity:
2285 # all memory and object allocations.
2286 # 
2287 # Enabling stress mode will degrade performance, it is only for debugging.
2288 def self.stress= bool; true || false; end
2289 ##
2290 # The number of times GC occurred.
2291 # 
2292 # It returns the number of times GC occurred since the process started.
2293 def self.count; 0; end
2294 ##
2295 # Returns a Hash containing information about the GC.
2296 # 
2297 # The hash includes information about internal statistics about GC such as:
2298 # 
2299 #     {
2300 #         :count=>0,
2301 #         :heap_used=>12,
2302 #         :heap_length=>12,
2303 #         :heap_increment=>0,
2304 #         :heap_live_num=>7539,
2305 #         :heap_free_num=>88,
2306 #         :heap_final_num=>0,
2307 #         :total_allocated_object=>7630,
2308 #         :total_freed_object=>88
2309 #     }
2310 # 
2311 # The contents of the hash are implementation specific and may be changed in
2312 # the future.
2313 # 
2314 # This method is only expected to work on C Ruby.
2315 def self.stat; {}; end
2316 ##
2317 # Returns the size of memory allocated by malloc().
2318 # 
2319 # Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
2320 def self.malloc_allocated_size; 0; end
2321 ##
2322 # Returns the number of malloc() allocations.
2323 # 
2324 # Only available if ruby was built with +CALC_EXACT_MALLOC_SIZE+.
2325 def self.malloc_allocations; 0; end
2326 end
2327 
2328 ##
2329 # The ObjectSpace module contains a number of routines
2330 # that interact with the garbage collection facility and allow you to
2331 # traverse all living objects with an iterator.
2332 # 
2333 # ObjectSpace also provides support for object finalizers, procs that will be
2334 # called when a specific object is about to be destroyed by garbage
2335 # collection.
2336 # 
2337 #    include ObjectSpace
2338 # 
2339 #    a = "A"
2340 #    b = "B"
2341 #    c = "C"
2342 # 
2343 #    define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
2344 #    define_finalizer(a, proc {|id| puts "Finalizer two on #{id}" })
2345 #    define_finalizer(b, proc {|id| puts "Finalizer three on #{id}" })
2346 # 
2347 # _produces:_
2348 # 
2349 #    Finalizer three on 537763470
2350 #    Finalizer one on 537763480
2351 #    Finalizer two on 537763480
2352 module ObjectSpace
2353 ##
2354 # An ObjectSpace::WeakMap object holds references to
2355 # any objects, but those objects can get garbage collected.
2356 # 
2357 # This class is mostly used internally by WeakRef, please use
2358 # +lib/weakref.rb+ for the public interface.
2359 class WeakMap < Object
2360 end
2361 
2362 ##
2363 # Calls the block once for each living, nonimmediate object in this
2364 # Ruby process. If <i>module</i> is specified, calls the block
2365 # for only those classes or modules that match (or are a subclass of)
2366 # <i>module</i>. Returns the number of objects found. Immediate
2367 # objects (<code>Fixnum</code>s, <code>Symbol</code>s
2368 # <code>true</code>, <code>false</code>, and <code>nil</code>) are
2369 # never returned. In the example below, <code>each_object</code>
2370 # returns both the numbers we defined and several constants defined in
2371 # the <code>Math</code> module.
2372 # 
2373 # If no block is given, an enumerator is returned instead.
2374 # 
2375 #    a = 102.7
2376 #    b = 95       # Won't be returned
2377 #    c = 12345678987654321
2378 #    count = ObjectSpace.each_object(Numeric) {|x| p x }
2379 #    puts "Total count: #{count}"
2380 # 
2381 # <em>produces:</em>
2382 # 
2383 #    12345678987654321
2384 #    102.7
2385 #    2.71828182845905
2386 #    3.14159265358979
2387 #    2.22044604925031e-16
2388 #    1.7976931348623157e+308
2389 #    2.2250738585072e-308
2390 #    Total count: 7
2391 def self.each_object(modul=0, &block); Enumerator.new; end
2392 ##
2393 # Initiates garbage collection, unless manually disabled.
2394 def self.start; end
2395 ##
2396 # Initiates garbage collection, unless manually disabled.
2397 def self.garbage_collect; end
2398 ##
2399 # Adds <i>aProc</i> as a finalizer, to be called after <i>obj</i>
2400 # was destroyed.
2401 def self.define_finalizer(obj, aProc=pro); end
2402 ##
2403 # Removes all finalizers for <i>obj</i>.
2404 def self.undefine_finalizer(obj); end
2405 ##
2406 # Converts an object id to a reference to the object. May not be
2407 # called on an object id passed as a parameter to a finalizer.
2408 # 
2409 #    s = "I am a string"                    #=> "I am a string"
2410 #    r = ObjectSpace._id2ref(s.object_id)   #=> "I am a string"
2411 #    r == s                                 #=> true
2412 def self._id2ref(object_id); Object.new; end
2413 ##
2414 # Counts objects for each type.
2415 # 
2416 # It returns a hash, such as:
2417 #     {
2418 #       :TOTAL=>10000,
2419 #       :FREE=>3011,
2420 #       :T_OBJECT=>6,
2421 #       :T_CLASS=>404,
2422 #       # ...
2423 #     }
2424 # 
2425 # The contents of the returned hash are implementation specific.
2426 # It may be changed in future.
2427 # 
2428 # If the optional argument +result_hash+ is given,
2429 # it is overwritten and returned. This is intended to avoid probe effect.
2430 # 
2431 # This method is only expected to work on C Ruby.
2432 def self.count_objects(result_hash=0); {}; end
2433 end
2434 
2435 ##
2436 # <code>FileTest</code> implements file test operations similar to
2437 # those used in <code>File::Stat</code>. It exists as a standalone
2438 # module, and its methods are also insinuated into the <code>File</code>
2439 # class. (Note that this is not done by inclusion: the interpreter cheats).
2440 module FileTest
2441 ##
2442 # Returns <code>true</code> if the named file is a directory,
2443 # or a symlink that points at a directory, and <code>false</code>
2444 # otherwise.
2445 # 
2446 #    File.directory?(".")
2447 def directory?(file_name); true || false; end
2448 ##
2449 # Return <code>true</code> if the named file exists.
2450 def exist?(file_name); true || false; end
2451 ##
2452 # Return <code>true</code> if the named file exists.
2453 def exists?(file_name); true || false; end
2454 ##
2455 # Returns <code>true</code> if the named file is readable by the effective
2456 # user id of this process.
2457 def readable?(file_name); true || false; end
2458 ##
2459 # Returns <code>true</code> if the named file is readable by the real
2460 # user id of this process.
2461 def readable_real?(file_name); true || false; end
2462 ##
2463 # If <i>file_name</i> is readable by others, returns an integer
2464 # representing the file permission bits of <i>file_name</i>. Returns
2465 # <code>nil</code> otherwise. The meaning of the bits is platform
2466 # dependent; on Unix systems, see <code>stat(2)</code>.
2467 # 
2468 #    File.world_readable?("/etc/passwd")           #=> 420
2469 #    m = File.world_readable?("/etc/passwd")
2470 #    sprintf("%o", m)                              #=> "644"
2471 def world_readable?(file_name); 1 || nil; end
2472 ##
2473 # Returns <code>true</code> if the named file is writable by the effective
2474 # user id of this process.
2475 def writable?(file_name); true || false; end
2476 ##
2477 # Returns <code>true</code> if the named file is writable by the real
2478 # user id of this process.
2479 def writable_real?(file_name); true || false; end
2480 ##
2481 # If <i>file_name</i> is writable by others, returns an integer
2482 # representing the file permission bits of <i>file_name</i>. Returns
2483 # <code>nil</code> otherwise. The meaning of the bits is platform
2484 # dependent; on Unix systems, see <code>stat(2)</code>.
2485 # 
2486 #    File.world_writable?("/tmp")                  #=> 511
2487 #    m = File.world_writable?("/tmp")
2488 #    sprintf("%o", m)                              #=> "777"
2489 def world_writable?(file_name); 1 || nil; end
2490 ##
2491 # Returns <code>true</code> if the named file is executable by the effective
2492 # user id of this process.
2493 def executable?(file_name); true || false; end
2494 ##
2495 # Returns <code>true</code> if the named file is executable by the real
2496 # user id of this process.
2497 def executable_real?(file_name); true || false; end
2498 ##
2499 # Returns <code>true</code> if the named file exists and is a
2500 # regular file.
2501 def file?(file_name); true || false; end
2502 ##
2503 # Returns <code>true</code> if the named file exists and has
2504 # a zero size.
2505 def zero?(file_name); true || false; end
2506 ##
2507 # Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the
2508 # file otherwise.
2509 def size?(file_name); 0 || nil; end
2510 ##
2511 # Returns the size of <code>file_name</code>.
2512 def size(file_name); 0; end
2513 ##
2514 # Returns <code>true</code> if the named file exists and the
2515 # effective used id of the calling process is the owner of
2516 # the file.
2517 def owned?(file_name); true || false; end
2518 ##
2519 # Returns <code>true</code> if the named file exists and the
2520 # effective group id of the calling process is the owner of
2521 # the file. Returns <code>false</code> on Windows.
2522 def grpowned?(file_name); true || false; end
2523 ##
2524 # Returns <code>true</code> if the named file is a pipe.
2525 def pipe?(file_name); true || false; end
2526 ##
2527 # Returns <code>true</code> if the named file is a symbolic link.
2528 def symlink?(file_name); true || false; end
2529 ##
2530 # Returns <code>true</code> if the named file is a socket.
2531 def socket?(file_name); true || false; end
2532 ##
2533 # Returns <code>true</code> if the named file is a block device.
2534 def blockdev?(file_name); true || false; end
2535 ##
2536 # Returns <code>true</code> if the named file is a character device.
2537 def chardev?(file_name); true || false; end
2538 ##
2539 # Returns <code>true</code> if the named file has the setuid bit set.
2540 def setuid?(file_name); true || false; end
2541 ##
2542 # Returns <code>true</code> if the named file has the setgid bit set.
2543 def setgid?(file_name); true || false; end
2544 ##
2545 # Returns <code>true</code> if the named file has the sticky bit set.
2546 def sticky?(file_name); true || false; end
2547 ##
2548 # Returns <code>true</code> if the named files are identical.
2549 # 
2550 #     open("a", "w") {}
2551 #     p File.identical?("a", "a")      #=> true
2552 #     p File.identical?("a", "./a")    #=> true
2553 #     File.link("a", "b")
2554 #     p File.identical?("a", "b")      #=> true
2555 #     File.symlink("a", "c")
2556 #     p File.identical?("a", "c")      #=> true
2557 #     open("d", "w") {}
2558 #     p File.identical?("a", "d")      #=> false
2559 def identical?(file_1, file_2); true || false; end
2560 end
2561 
2562 ##
2563 # The <code>Comparable</code> mixin is used by classes whose objects
2564 # may be ordered. The class must define the <code><=></code> operator,
2565 # which compares the receiver against another object, returning -1, 0,
2566 # or +1 depending on whether the receiver is less than, equal to, or
2567 # greater than the other object. If the other object is not comparable
2568 # then the <code><=></code> operator should return nil.
2569 # <code>Comparable</code> uses
2570 # <code><=></code> to implement the conventional comparison operators
2571 # (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
2572 # and <code>></code>) and the method <code>between?</code>.
2573 # 
2574 #    class SizeMatters
2575 #      include Comparable
2576 #      attr :str
2577 #      def <=>(anOther)
2578 #        str.size <=> anOther.str.size
2579 #      end
2580 #      def initialize(str)
2581 #        @str = str
2582 #      end
2583 #      def inspect
2584 #        @str
2585 #      end
2586 #    end
2587 # 
2588 #    s1 = SizeMatters.new("Z")
2589 #    s2 = SizeMatters.new("YY")
2590 #    s3 = SizeMatters.new("XXX")
2591 #    s4 = SizeMatters.new("WWWW")
2592 #    s5 = SizeMatters.new("VVVVV")
2593 # 
2594 #    s1 < s2                       #=> true
2595 #    s4.between?(s1, s3)           #=> false
2596 #    s4.between?(s3, s5)           #=> true
2597 #    [ s3, s2, s5, s4, s1 ].sort   #=> [Z, YY, XXX, WWWW, VVVVV]
2598 module Comparable
2599 ##
2600 # Compares two objects based on the receiver's <code><=></code>
2601 # method, returning true if it returns 0. Also returns true if
2602 # _obj_ and _other_ are the same object.
2603 # 
2604 # Even if _obj_ <=> _other_ raised an exception, the exception
2605 # is ignoread and returns false.
2606 def ==; true || false; end
2607 ##
2608 # Compares two objects based on the receiver's <code><=></code>
2609 # method, returning true if it returns 1.
2610 def >; true || false; end
2611 ##
2612 # Compares two objects based on the receiver's <code><=></code>
2613 # method, returning true if it returns 0 or 1.
2614 def >=; true || false; end
2615 ##
2616 # Compares two objects based on the receiver's <code><=></code>
2617 # method, returning true if it returns -1.
2618 def <; true || false; end
2619 ##
2620 # Compares two objects based on the receiver's <code><=></code>
2621 # method, returning true if it returns -1 or 0.
2622 def <=; true || false; end
2623 ##
2624 # Returns <code>false</code> if <i>obj</i> <code><=></code>
2625 # <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
2626 # <i>max</i> is greater than zero, <code>true</code> otherwise.
2627 # 
2628 #    3.between?(1, 5)               #=> true
2629 #    6.between?(1, 5)               #=> false
2630 #    'cat'.between?('ant', 'dog')   #=> true
2631 #    'gnu'.between?('ant', 'dog')   #=> false
2632 def between?(min, max); true || false; end
2633 end
2634 
2635 ##
2636 # The <code>Process</code> module is a collection of methods used to
2637 # manipulate processes.
2638 module Process
2639 ##
2640 # <code>Process::Status</code> encapsulates the information on the
2641 # status of a running or terminated system process. The built-in
2642 # variable <code>$?</code> is either +nil+ or a
2643 # <code>Process::Status</code> object.
2644 # 
2645 #    fork { exit 99 }   #=> 26557
2646 #    Process.wait       #=> 26557
2647 #    $?.class           #=> Process::Status
2648 #    $?.to_i            #=> 25344
2649 #    $? >> 8            #=> 99
2650 #    $?.stopped?        #=> false
2651 #    $?.exited?         #=> true
2652 #    $?.exitstatus      #=> 99
2653 # 
2654 # Posix systems record information on processes using a 16-bit
2655 # integer.  The lower bits record the process status (stopped,
2656 # exited, signaled) and the upper bits possibly contain additional
2657 # information (for example the program's return code in the case of
2658 # exited processes). Pre Ruby 1.8, these bits were exposed directly
2659 # to the Ruby program. Ruby now encapsulates these in a
2660 # <code>Process::Status</code> object. To maximize compatibility,
2661 # however, these objects retain a bit-oriented interface. In the
2662 # descriptions that follow, when we talk about the integer value of
2663 # _stat_, we're referring to this 16 bit value.
2664 class Status < Object
2665 ##
2666 # Returns +true+ if the integer value of _stat_
2667 # equals <em>other</em>.
2668 def ==; true || false; end
2669 ##
2670 # Logical AND of the bits in _stat_ with <em>num</em>.
2671 # 
2672 #    fork { exit 0x37 }
2673 #    Process.wait
2674 #    sprintf('%04x', $?.to_i)       #=> "3700"
2675 #    sprintf('%04x', $? & 0x1e00)   #=> "1600"
2676 def &; 0; end
2677 ##
2678 # Shift the bits in _stat_ right <em>num</em> places.
2679 # 
2680 #    fork { exit 99 }   #=> 26563
2681 #    Process.wait       #=> 26563
2682 #    $?.to_i            #=> 25344
2683 #    $? >> 8            #=> 99
2684 def >>; 0; end
2685 ##
2686 # Returns the bits in _stat_ as a <code>Fixnum</code>. Poking
2687 # around in these bits is platform dependent.
2688 # 
2689 #    fork { exit 0xab }         #=> 26566
2690 #    Process.wait               #=> 26566
2691 #    sprintf('%04x', $?.to_i)   #=> "ab00"
2692 def to_i; 0; end
2693 ##
2694 # Returns the bits in _stat_ as a <code>Fixnum</code>. Poking
2695 # around in these bits is platform dependent.
2696 # 
2697 #    fork { exit 0xab }         #=> 26566
2698 #    Process.wait               #=> 26566
2699 #    sprintf('%04x', $?.to_i)   #=> "ab00"
2700 def to_int; 0; end
2701 ##
2702 # Show pid and exit status as a string.
2703 # 
2704 #   system("false")
2705 #   p $?.to_s         #=> "pid 12766 exit 1"
2706 def to_s; ''; end
2707 ##
2708 # Override the inspection method.
2709 # 
2710 #   system("false")
2711 #   p $?.inspect #=> "#<Process::Status: pid 12861 exit 1>"
2712 def inspect; ''; end
2713 ##
2714 # Returns the process ID that this status object represents.
2715 # 
2716 #    fork { exit }   #=> 26569
2717 #    Process.wait    #=> 26569
2718 #    $?.pid          #=> 26569
2719 def pid; 0; end
2720 ##
2721 # Returns +true+ if this process is stopped. This is only
2722 # returned if the corresponding <code>wait</code> call had the
2723 # <code>WUNTRACED</code> flag set.
2724 def stopped?; true || false; end
2725 ##
2726 # Returns the number of the signal that caused _stat_ to stop
2727 # (or +nil+ if self is not stopped).
2728 def stopsig; 1 || nil; end
2729 ##
2730 # Returns +true+ if _stat_ terminated because of
2731 # an uncaught signal.
2732 def signaled?; true || false; end
2733 ##
2734 # Returns the number of the signal that caused _stat_ to
2735 # terminate (or +nil+ if self was not terminated by an
2736 # uncaught signal).
2737 def termsig; 1 || nil; end
2738 ##
2739 # Returns +true+ if _stat_ exited normally (for
2740 # example using an <code>exit()</code> call or finishing the
2741 # program).
2742 def exited?; true || false; end
2743 ##
2744 # Returns the least significant eight bits of the return code of
2745 # _stat_. Only available if <code>exited?</code> is
2746 # +true+.
2747 # 
2748 #    fork { }           #=> 26572
2749 #    Process.wait       #=> 26572
2750 #    $?.exited?         #=> true
2751 #    $?.exitstatus      #=> 0
2752 # 
2753 #    fork { exit 99 }   #=> 26573
2754 #    Process.wait       #=> 26573
2755 #    $?.exited?         #=> true
2756 #    $?.exitstatus      #=> 99
2757 def exitstatus; 1 || nil; end
2758 ##
2759 # Returns +true+ if _stat_ is successful, +false+ if not.
2760 # Returns +nil+ if <code>exited?</code> is not +true+.
2761 def success?; true || false || nil; end
2762 ##
2763 # Returns +true+ if _stat_ generated a coredump
2764 # when it terminated. Not available on all platforms.
2765 def coredump?; true || false; end
2766 end
2767 
2768 ##
2769 # Replaces the current process by running the given external _command_.
2770 # _command..._ is one of following forms.
2771 # 
2772 #   commandline                 : command line string which is passed to the standard shell
2773 #   cmdname, arg1, ...          : command name and one or more arguments (no shell)
2774 #   [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
2775 # 
2776 # If single string is given as the command,
2777 # it is taken as a command line that is subject to shell expansion before being executed.
2778 # 
2779 # The standard shell means always <code>"/bin/sh"</code> on Unix-like systems,
2780 # <code>ENV["RUBYSHELL"]</code> or <code>ENV["COMSPEC"]</code> on Windows NT series, and
2781 # similar.
2782 # 
2783 # If two or more +string+ given,
2784 # the first is taken as a command name and
2785 # the rest are passed as parameters to command with no shell expansion.
2786 # 
2787 # If a two-element array at the beginning of the command,
2788 # the first element is the command to be executed,
2789 # and the second argument is used as the <code>argv[0]</code> value,
2790 # which may show up in process listings.
2791 # 
2792 # In order to execute the command, one of the <code>exec(2)</code>
2793 # system calls is used, so the running command may inherit some of the environment
2794 # of the original program (including open file descriptors).
2795 # This behavior is modified by env and options.
2796 # See <code>spawn</code> for details.
2797 # 
2798 # Raises SystemCallError if the command couldn't execute (typically
2799 # <code>Errno::ENOENT</code> when it was not found).
2800 # 
2801 # This method modifies process attributes according to _options_
2802 # (details described in <code>spawn</code>)
2803 # before <code>exec(2)</code> system call.
2804 # The modified attributes may be retained when <code>exec(2)</code> system call fails.
2805 # For example, hard resource limits is not restorable.
2806 # If it is not acceptable, consider to create a child process using <code>spawn</code> or <code>system</code>.
2807 # 
2808 #    exec "echo *"       # echoes list of files in current directory
2809 #    # never get here
2810 # 
2811 #    exec "echo", "*"    # echoes an asterisk
2812 #    # never get here
2813 def self.exec(env=0, command=0, options=0); end
2814 ##
2815 # Creates a subprocess. If a block is specified, that block is run
2816 # in the subprocess, and the subprocess terminates with a status of
2817 # zero. Otherwise, the +fork+ call returns twice, once in
2818 # the parent, returning the process ID of the child, and once in
2819 # the child, returning _nil_. The child process can exit using
2820 # <code>Kernel.exit!</code> to avoid running any
2821 # <code>at_exit</code> functions. The parent process should
2822 # use <code>Process.wait</code> to collect the termination statuses
2823 # of its children or use <code>Process.detach</code> to register
2824 # disinterest in their status; otherwise, the operating system
2825 # may accumulate zombie processes.
2826 # 
2827 # The thread calling fork is the only thread in the created child process.
2828 # fork doesn't copy other threads.
2829 # 
2830 # If fork is not usable, Process.respond_to?(:fork) returns false.
2831 def self.fork; 1 || nil; end
2832 ##
2833 # spawn executes specified command and return its pid.
2834 # 
2835 # This method doesn't wait for end of the command.
2836 # The parent process should
2837 # use <code>Process.wait</code> to collect
2838 # the termination status of its child or
2839 # use <code>Process.detach</code> to register
2840 # disinterest in their status;
2841 # otherwise, the operating system may accumulate zombie processes.
2842 # 
2843 # spawn has bunch of options to specify process attributes:
2844 # 
2845 #   env: hash
2846 #     name => val : set the environment variable
2847 #     name => nil : unset the environment variable
2848 #   command...:
2849 #     commandline                 : command line string which is passed to the standard shell
2850 #     cmdname, arg1, ...          : command name and one or more arguments (no shell)
2851 #     [cmdname, argv0], arg1, ... : command name, argv[0] and zero or more arguments (no shell)
2852 #   options: hash
2853 #     clearing environment variables:
2854 #       :unsetenv_others => true   : clear environment variables except specified by env
2855 #       :unsetenv_others => false  : don't clear (default)
2856 #     process group:
2857 #       :pgroup => true or 0 : make a new process group
2858 #       :pgroup => pgid      : join to specified process group
2859 #       :pgroup => nil       : don't change the process group (default)
2860 #     create new process group: Windows only
2861 #       :new_pgroup => true  : the new process is the root process of a new process group
2862 #       :new_pgroup => false : don't create a new process group (default)
2863 #     resource limit: resourcename is core, cpu, data, etc.  See Process.setrlimit.
2864 #       :rlimit_resourcename => limit
2865 #       :rlimit_resourcename => [cur_limit, max_limit]
2866 #     umask:
2867 #       :umask => int
2868 #     redirection:
2869 #       key:
2870 #         FD              : single file descriptor in child process
2871 #         [FD, FD, ...]   : multiple file descriptor in child process
2872 #       value:
2873 #         FD                        : redirect to the file descriptor in parent process
2874 #         string                    : redirect to file with open(string, "r" or "w")
2875 #         [string]                  : redirect to file with open(string, File::RDONLY)
2876 #         [string, open_mode]       : redirect to file with open(string, open_mode, 0644)
2877 #         [string, open_mode, perm] : redirect to file with open(string, open_mode, perm)
2878 #         [:child, FD]              : redirect to the redirected file descriptor
2879 #         :close                    : close the file descriptor in child process
2880 #       FD is one of follows
2881 #         :in     : the file descriptor 0 which is the standard input
2882 #         :out    : the file descriptor 1 which is the standard output
2883 #         :err    : the file descriptor 2 which is the standard error
2884 #         integer : the file descriptor of specified the integer
2885 #         io      : the file descriptor specified as io.fileno
2886 #     file descriptor inheritance: close non-redirected non-standard fds (3, 4, 5, ...) or not
2887 #       :close_others => true  : don't inherit
2888 #     current directory:
2889 #       :chdir => str
2890 # 
2891 # If a hash is given as +env+, the environment is
2892 # updated by +env+ before <code>exec(2)</code> in the child process.
2893 # If a pair in +env+ has nil as the value, the variable is deleted.
2894 # 
2895 #   # set FOO as BAR and unset BAZ.
2896 #   pid = spawn({"FOO"=>"BAR", "BAZ"=>nil}, command)
2897 # 
2898 # If a hash is given as +options+,
2899 # it specifies
2900 # process group,
2901 # create new process group,
2902 # resource limit,
2903 # current directory,
2904 # umask and
2905 # redirects for the child process.
2906 # Also, it can be specified to clear environment variables.
2907 # 
2908 # The <code>:unsetenv_others</code> key in +options+ specifies
2909 # to clear environment variables, other than specified by +env+.
2910 # 
2911 #   pid = spawn(command, :unsetenv_others=>true) # no environment variable
2912 #   pid = spawn({"FOO"=>"BAR"}, command, :unsetenv_others=>true) # FOO only
2913 # 
2914 # The <code>:pgroup</code> key in +options+ specifies a process group.
2915 # The corresponding value should be true, zero or positive integer.
2916 # true and zero means the process should be a process leader of a new
2917 # process group.
2918 # Other values specifies a process group to be belongs.
2919 # 
2920 #   pid = spawn(command, :pgroup=>true) # process leader
2921 #   pid = spawn(command, :pgroup=>10) # belongs to the process group 10
2922 # 
2923 # The <code>:new_pgroup</code> key in +options+ specifies to pass
2924 # +CREATE_NEW_PROCESS_GROUP+ flag to <code>CreateProcessW()</code> that is
2925 # Windows API. This option is only for Windows.
2926 # true means the new process is the root process of the new process group.
2927 # The new process has CTRL+C disabled. This flag is necessary for
2928 # <code>Process.kill(:SIGINT, pid)</code> on the subprocess.
2929 # :new_pgroup is false by default.
2930 # 
2931 #   pid = spawn(command, :new_pgroup=>true)  # new process group
2932 #   pid = spawn(command, :new_pgroup=>false) # same process group
2933 # 
2934 # The <code>:rlimit_</code><em>foo</em> key specifies a resource limit.
2935 # <em>foo</em> should be one of resource types such as <code>core</code>.
2936 # The corresponding value should be an integer or an array which have one or
2937 # two integers: same as cur_limit and max_limit arguments for
2938 # Process.setrlimit.
2939 # 
2940 #   cur, max = Process.getrlimit(:CORE)
2941 #   pid = spawn(command, :rlimit_core=>[0,max]) # disable core temporary.
2942 #   pid = spawn(command, :rlimit_core=>max) # enable core dump
2943 #   pid = spawn(command, :rlimit_core=>0) # never dump core.
2944 # 
2945 # The <code>:umask</code> key in +options+ specifies the umask.
2946 # 
2947 #   pid = spawn(command, :umask=>077)
2948 # 
2949 # The :in, :out, :err, a fixnum, an IO and an array key specifies a redirection.
2950 # The redirection maps a file descriptor in the child process.
2951 # 
2952 # For example, stderr can be merged into stdout as follows:
2953 # 
2954 #   pid = spawn(command, :err=>:out)
2955 #   pid = spawn(command, 2=>1)
2956 #   pid = spawn(command, STDERR=>:out)
2957 #   pid = spawn(command, STDERR=>STDOUT)
2958 # 
2959 # The hash keys specifies a file descriptor
2960 # in the child process started by <code>spawn</code>.
2961 # :err, 2 and STDERR specifies the standard error stream (stderr).
2962 # 
2963 # The hash values specifies a file descriptor
2964 # in the parent process which invokes <code>spawn</code>.
2965 # :out, 1 and STDOUT specifies the standard output stream (stdout).
2966 # 
2967 # In the above example,
2968 # the standard output in the child process is not specified.
2969 # So it is inherited from the parent process.
2970 # 
2971 # The standard input stream (stdin) can be specified by :in, 0 and STDIN.
2972 # 
2973 # A filename can be specified as a hash value.
2974 # 
2975 #   pid = spawn(command, :in=>"/dev/null") # read mode
2976 #   pid = spawn(command, :out=>"/dev/null") # write mode
2977 #   pid = spawn(command, :err=>"log") # write mode
2978 #   pid = spawn(command, 3=>"/dev/null") # read mode
2979 # 
2980 # For stdout and stderr,
2981 # it is opened in write mode.
2982 # Otherwise read mode is used.
2983 # 
2984 # For specifying flags and permission of file creation explicitly,
2985 # an array is used instead.
2986 # 
2987 #   pid = spawn(command, :in=>["file"]) # read mode is assumed
2988 #   pid = spawn(command, :in=>["file", "r"])
2989 #   pid = spawn(command, :out=>["log", "w"]) # 0644 assumed
2990 #   pid = spawn(command, :out=>["log", "w", 0600])
2991 #   pid = spawn(command, :out=>["log", File::WRONLY|File::EXCL|File::CREAT, 0600])
2992 # 
2993 # The array specifies a filename, flags and permission.
2994 # The flags can be a string or an integer.
2995 # If the flags is omitted or nil, File::RDONLY is assumed.
2996 # The permission should be an integer.
2997 # If the permission is omitted or nil, 0644 is assumed.
2998 # 
2999 # If an array of IOs and integers are specified as a hash key,
3000 # all the elements are redirected.
3001 # 
3002 #   # stdout and stderr is redirected to log file.
3003 #   # The file "log" is opened just once.
3004 #   pid = spawn(command, [:out, :err]=>["log", "w"])
3005 # 
3006 # Another way to merge multiple file descriptors is [:child, fd].
3007 # \[:child, fd] means the file descriptor in the child process.
3008 # This is different from fd.
3009 # For example, :err=>:out means redirecting child stderr to parent stdout.
3010 # But :err=>[:child, :out] means redirecting child stderr to child stdout.
3011 # They differ if stdout is redirected in the child process as follows.
3012 # 
3013 #   # stdout and stderr is redirected to log file.
3014 #   # The file "log" is opened just once.
3015 #   pid = spawn(command, :out=>["log", "w"], :err=>[:child, :out])
3016 # 
3017 # \[:child, :out] can be used to merge stderr into stdout in IO.popen.
3018 # In this case, IO.popen redirects stdout to a pipe in the child process
3019 # and [:child, :out] refers the redirected stdout.
3020 # 
3021 #   io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
3022 #   p io.read #=> "out\nerr\n"
3023 # 
3024 # The <code>:chdir</code> key in +options+ specifies the current directory.
3025 # 
3026 #   pid = spawn(command, :chdir=>"/var/tmp")
3027 # 
3028 # spawn closes all non-standard unspecified descriptors by default.
3029 # The "standard" descriptors are 0, 1 and 2.
3030 # This behavior is specified by :close_others option.
3031 # :close_others doesn't affect the standard descriptors which are
3032 # closed only if :close is specified explicitly.
3033 # 
3034 #   pid = spawn(command, :close_others=>true)  # close 3,4,5,... (default)
3035 #   pid = spawn(command, :close_others=>false) # don't close 3,4,5,...
3036 # 
3037 # :close_others is true by default for spawn and IO.popen.
3038 # 
3039 # Note that fds which close-on-exec flag is already set are closed
3040 # regardless of :close_others option.
3041 # 
3042 # So IO.pipe and spawn can be used as IO.popen.
3043 # 
3044 #   # similar to r = IO.popen(command)
3045 #   r, w = IO.pipe
3046 #   pid = spawn(command, :out=>w)   # r, w is closed in the child process.
3047 #   w.close
3048 # 
3049 # :close is specified as a hash value to close a fd individually.
3050 # 
3051 #   f = open(foo)
3052 #   system(command, f=>:close)        # don't inherit f.
3053 # 
3054 # If a file descriptor need to be inherited,
3055 # io=>io can be used.
3056 # 
3057 #   # valgrind has --log-fd option for log destination.
3058 #   # log_w=>log_w indicates log_w.fileno inherits to child process.
3059 #   log_r, log_w = IO.pipe
3060 #   pid = spawn("valgrind", "--log-fd=#{log_w.fileno}", "echo", "a", log_w=>log_w)
3061 #   log_w.close
3062 #   p log_r.read
3063 # 
3064 # It is also possible to exchange file descriptors.
3065 # 
3066 #   pid = spawn(command, :out=>:err, :err=>:out)
3067 # 
3068 # The hash keys specify file descriptors in the child process.
3069 # The hash values specifies file descriptors in the parent process.
3070 # So the above specifies exchanging stdout and stderr.
3071 # Internally, +spawn+ uses an extra file descriptor to resolve such cyclic
3072 # file descriptor mapping.
3073 # 
3074 # See <code>Kernel.exec</code> for the standard shell.
3075 def self.spawn(env=0, command=0, options=0); 0; end
3076 ##
3077 # Exits the process immediately. No exit handlers are
3078 # run. <em>status</em> is returned to the underlying system as the
3079 # exit status.
3080 # 
3081 #    Process.exit!(true)
3082 def self.exit!(status=false); end
3083 ##
3084 # Initiates the termination of the Ruby script by raising the
3085 # <code>SystemExit</code> exception. This exception may be caught. The
3086 # optional parameter is used to return a status code to the invoking
3087 # environment.
3088 # +true+ and +FALSE+ of _status_ means success and failure
3089 # respectively.  The interpretation of other integer values are
3090 # system dependent.
3091 # 
3092 #    begin
3093 #      exit
3094 #      puts "never get here"
3095 #    rescue SystemExit
3096 #      puts "rescued a SystemExit exception"
3097 #    end
3098 #    puts "after begin block"
3099 # 
3100 # <em>produces:</em>
3101 # 
3102 #    rescued a SystemExit exception
3103 #    after begin block
3104 # 
3105 # Just prior to termination, Ruby executes any <code>at_exit</code> functions
3106 # (see Kernel::at_exit) and runs any object finalizers (see
3107 # ObjectSpace::define_finalizer).
3108 # 
3109 #    at_exit { puts "at_exit function" }
3110 #    ObjectSpace.define_finalizer("string",  proc { puts "in finalizer" })
3111 #    exit
3112 # 
3113 # <em>produces:</em>
3114 # 
3115 #    at_exit function
3116 #    in finalizer
3117 def self.exit(status=true); end
3118 ##
3119 # Terminate execution immediately, effectively by calling
3120 # <code>Kernel.exit(false)</code>. If _msg_ is given, it is written
3121 # to STDERR prior to terminating.
3122 def self.abort; end
3123 ##
3124 # Sends the given signal to the specified process id(s) if _pid_ is positive.
3125 # If _pid_ is zero _signal_ is sent to all processes whose group ID is equal
3126 # to the group ID of the process. _signal_ may be an integer signal number or
3127 # a POSIX signal name (either with or without a +SIG+ prefix). If _signal_ is
3128 # negative (or starts with a minus sign), kills process groups instead of
3129 # processes. Not all signals are available on all platforms.
3130 # 
3131 #    pid = fork do
3132 #       Signal.trap("HUP") { puts "Ouch!"; exit }
3133 #       # ... do some work ...
3134 #    end
3135 #    # ...
3136 #    Process.kill("HUP", pid)
3137 #    Process.wait
3138 # 
3139 # <em>produces:</em>
3140 # 
3141 #    Ouch!
3142 # 
3143 # If _signal_ is an integer but wrong for signal,
3144 # <code>Errno::EINVAL</code> or +RangeError+ will be raised.
3145 # Otherwise unless _signal_ is a +String+ or a +Symbol+, and a known
3146 # signal name, +ArgumentError+ will be raised.
3147 # 
3148 # Also, <code>Errno::ESRCH</code> or +RangeError+ for invalid _pid_,
3149 # <code>Errno::EPERM</code> when failed because of no privilege,
3150 # will be raised.  In these cases, signals may have been sent to
3151 # preceding processes.
3152 def self.kill(); 0; end
3153 ##
3154 # Waits for a child process to exit, returns its process id, and
3155 # sets <code>$?</code> to a <code>Process::Status</code> object
3156 # containing information on that process. Which child it waits on
3157 # depends on the value of _pid_:
3158 # 
3159 # > 0::   Waits for the child whose process ID equals _pid_.
3160 # 
3161 # 0::     Waits for any child whose process group ID equals that of the
3162 #         calling process.
3163 # 
3164 # -1::    Waits for any child process (the default if no _pid_ is
3165 #         given).
3166 # 
3167 # < -1::  Waits for any child whose process group ID equals the absolute
3168 #         value of _pid_.
3169 # 
3170 # The _flags_ argument may be a logical or of the flag values
3171 # <code>Process::WNOHANG</code> (do not block if no child available)
3172 # or <code>Process::WUNTRACED</code> (return stopped children that
3173 # haven't been reported). Not all flags are available on all
3174 # platforms, but a flag value of zero will work on all platforms.
3175 # 
3176 # Calling this method raises a SystemCallError if there are no child
3177 # processes. Not available on all platforms.
3178 # 
3179 #    include Process
3180 #    fork { exit 99 }                 #=> 27429
3181 #    wait                             #=> 27429
3182 #    $?.exitstatus                    #=> 99
3183 # 
3184 #    pid = fork { sleep 3 }           #=> 27440
3185 #    Time.now                         #=> 2008-03-08 19:56:16 +0900
3186 #    waitpid(pid, Process::WNOHANG)   #=> nil
3187 #    Time.now                         #=> 2008-03-08 19:56:16 +0900
3188 #    waitpid(pid, 0)                  #=> 27440
3189 #    Time.now                         #=> 2008-03-08 19:56:19 +0900
3190 def self.wait(); 0; end
3191 ##
3192 # Waits for a child process to exit, returns its process id, and
3193 # sets <code>$?</code> to a <code>Process::Status</code> object
3194 # containing information on that process. Which child it waits on
3195 # depends on the value of _pid_:
3196 # 
3197 # > 0::   Waits for the child whose process ID equals _pid_.
3198 # 
3199 # 0::     Waits for any child whose process group ID equals that of the
3200 #         calling process.
3201 # 
3202 # -1::    Waits for any child process (the default if no _pid_ is
3203 #         given).
3204 # 
3205 # < -1::  Waits for any child whose process group ID equals the absolute
3206 #         value of _pid_.
3207 # 
3208 # The _flags_ argument may be a logical or of the flag values
3209 # <code>Process::WNOHANG</code> (do not block if no child available)
3210 # or <code>Process::WUNTRACED</code> (return stopped children that
3211 # haven't been reported). Not all flags are available on all
3212 # platforms, but a flag value of zero will work on all platforms.
3213 # 
3214 # Calling this method raises a SystemCallError if there are no child
3215 # processes. Not available on all platforms.
3216 # 
3217 #    include Process
3218 #    fork { exit 99 }                 #=> 27429
3219 #    wait                             #=> 27429
3220 #    $?.exitstatus                    #=> 99
3221 # 
3222 #    pid = fork { sleep 3 }           #=> 27440
3223 #    Time.now                         #=> 2008-03-08 19:56:16 +0900
3224 #    waitpid(pid, Process::WNOHANG)   #=> nil
3225 #    Time.now                         #=> 2008-03-08 19:56:16 +0900
3226 #    waitpid(pid, 0)                  #=> 27440
3227 #    Time.now                         #=> 2008-03-08 19:56:19 +0900
3228 def self.waitpid(pid=-1, flags=0); 0; end
3229 ##
3230 # Waits for a child process to exit (see Process::waitpid for exact
3231 # semantics) and returns an array containing the process id and the
3232 # exit status (a <code>Process::Status</code> object) of that
3233 # child. Raises a SystemCallError if there are no child processes.
3234 # 
3235 #    Process.fork { exit 99 }   #=> 27437
3236 #    pid, status = Process.wait2
3237 #    pid                        #=> 27437
3238 #    status.exitstatus          #=> 99
3239 def self.wait2(pid=-1, flags=0); [1]; end
3240 ##
3241 # Waits for a child process to exit (see Process::waitpid for exact
3242 # semantics) and returns an array containing the process id and the
3243 # exit status (a <code>Process::Status</code> object) of that
3244 # child. Raises a SystemCallError if there are no child processes.
3245 # 
3246 #    Process.fork { exit 99 }   #=> 27437
3247 #    pid, status = Process.wait2
3248 #    pid                        #=> 27437
3249 #    status.exitstatus          #=> 99
3250 def self.waitpid2(pid=-1, flags=0); [1]; end
3251 ##
3252 # Waits for all children, returning an array of
3253 # _pid_/_status_ pairs (where _status_ is a
3254 # <code>Process::Status</code> object).
3255 # 
3256 #    fork { sleep 0.2; exit 2 }   #=> 27432
3257 #    fork { sleep 0.1; exit 1 }   #=> 27433
3258 #    fork {            exit 0 }   #=> 27434
3259 #    p Process.waitall
3260 # 
3261 # <em>produces</em>:
3262 # 
3263 #    [[30982, #<Process::Status: pid 30982 exit 0>],
3264 #     [30979, #<Process::Status: pid 30979 exit 1>],
3265 #     [30976, #<Process::Status: pid 30976 exit 2>]]
3266 def self.waitall; []; end
3267 ##
3268 # Some operating systems retain the status of terminated child
3269 # processes until the parent collects that status (normally using
3270 # some variant of <code>wait()</code>. If the parent never collects
3271 # this status, the child stays around as a <em>zombie</em> process.
3272 # <code>Process::detach</code> prevents this by setting up a
3273 # separate Ruby thread whose sole job is to reap the status of the
3274 # process _pid_ when it terminates. Use <code>detach</code>
3275 # only when you do not intent to explicitly wait for the child to
3276 # terminate.
3277 # 
3278 # The waiting thread returns the exit status of the detached process
3279 # when it terminates, so you can use <code>Thread#join</code> to
3280 # know the result.  If specified _pid_ is not a valid child process
3281 # ID, the thread returns +nil+ immediately.
3282 # 
3283 # The waiting thread has <code>pid</code> method which returns the pid.
3284 # 
3285 # In this first example, we don't reap the first child process, so
3286 # it appears as a zombie in the process status display.
3287 # 
3288 #    p1 = fork { sleep 0.1 }
3289 #    p2 = fork { sleep 0.2 }
3290 #    Process.waitpid(p2)
3291 #    sleep 2
3292 #    system("ps -ho pid,state -p #{p1}")
3293 # 
3294 # <em>produces:</em>
3295 # 
3296 #    27389 Z
3297 # 
3298 # In the next example, <code>Process::detach</code> is used to reap
3299 # the child automatically.
3300 # 
3301 #    p1 = fork { sleep 0.1 }
3302 #    p2 = fork { sleep 0.2 }
3303 #    Process.detach(p1)
3304 #    Process.waitpid(p2)
3305 #    sleep 2
3306 #    system("ps -ho pid,state -p #{p1}")
3307 # 
3308 # <em>(produces no output)</em>
3309 def self.detach(pid); Thread.new; end
3310 ##
3311 # Returns the process id of this process. Not available on all
3312 # platforms.
3313 # 
3314 #    Process.pid   #=> 27415
3315 def self.pid; 0; end
3316 ##
3317 # Returns the process id of the parent of this process. Returns
3318 # untrustworthy value on Win32/64. Not available on all platforms.
3319 # 
3320 #    puts "I am #{Process.pid}"
3321 #    Process.fork { puts "Dad is #{Process.ppid}" }
3322 # 
3323 # <em>produces:</em>
3324 # 
3325 #    I am 27417
3326 #    Dad is 27417
3327 def self.ppid; 0; end
3328 ##
3329 # Returns the process group ID for this process. Not available on
3330 # all platforms.
3331 # 
3332 #    Process.getpgid(0)   #=> 25527
3333 #    Process.getpgrp      #=> 25527
3334 def self.getpgrp; 0; end
3335 ##
3336 # Equivalent to <code>setpgid(0,0)</code>. Not available on all
3337 # platforms.
3338 def self.setpgrp; 0; end
3339 ##
3340 # Returns the process group ID for the given process id. Not
3341 # available on all platforms.
3342 # 
3343 #    Process.getpgid(Process.ppid())   #=> 25527
3344 def self.getpgid(pid); 0; end
3345 ##
3346 # Sets the process group ID of _pid_ (0 indicates this
3347 # process) to <em>integer</em>. Not available on all platforms.
3348 def self.setpgid(pid, integer); 0; end
3349 ##
3350 # Returns the session ID for for the given process id. If not give,
3351 # return current process sid. Not available on all platforms.
3352 # 
3353 #    Process.getsid()                #=> 27422
3354 #    Process.getsid(0)               #=> 27422
3355 #    Process.getsid(Process.pid())   #=> 27422
3356 def self.getsid(); 0; end
3357 ##
3358 # Establishes this process as a new session and process group
3359 # leader, with no controlling tty. Returns the session id. Not
3360 # available on all platforms.
3361 # 
3362 #    Process.setsid   #=> 27422
3363 def self.setsid; 0; end
3364 ##
3365 # Gets the scheduling priority for specified process, process group,
3366 # or user. <em>kind</em> indicates the kind of entity to find: one
3367 # of <code>Process::PRIO_PGRP</code>,
3368 # <code>Process::PRIO_USER</code>, or
3369 # <code>Process::PRIO_PROCESS</code>. _integer_ is an id
3370 # indicating the particular process, process group, or user (an id
3371 # of 0 means _current_). Lower priorities are more favorable
3372 # for scheduling. Not available on all platforms.
3373 # 
3374 #    Process.getpriority(Process::PRIO_USER, 0)      #=> 19
3375 #    Process.getpriority(Process::PRIO_PROCESS, 0)   #=> 19
3376 def self.getpriority(kind, integer); 0; end
3377 ##
3378 # See <code>Process#getpriority</code>.
3379 # 
3380 #    Process.setpriority(Process::PRIO_USER, 0, 19)      #=> 0
3381 #    Process.setpriority(Process::PRIO_PROCESS, 0, 19)   #=> 0
3382 #    Process.getpriority(Process::PRIO_USER, 0)          #=> 19
3383 #    Process.getpriority(Process::PRIO_PROCESS, 0)       #=> 19
3384 def self.setpriority(kind, integer, priority); 0; end
3385 ##
3386 # Gets the resource limit of the process.
3387 # _cur_limit_ means current (soft) limit and
3388 # _max_limit_ means maximum (hard) limit.
3389 # 
3390 # _resource_ indicates the kind of resource to limit.
3391 # It is specified as a symbol such as <code>:CORE</code>,
3392 # a string such as <code>"CORE"</code> or
3393 # a constant such as <code>Process::RLIMIT_CORE</code>.
3394 # See Process.setrlimit for details.
3395 # 
3396 # _cur_limit_ and _max_limit_ may be <code>Process::RLIM_INFINITY</code>,
3397 # <code>Process::RLIM_SAVED_MAX</code> or
3398 # <code>Process::RLIM_SAVED_CUR</code>.
3399 # See Process.setrlimit and the system getrlimit(2) manual for details.
3400 def self.getrlimit(resource); []; end
3401 ##
3402 # Sets the resource limit of the process.
3403 # _cur_limit_ means current (soft) limit and
3404 # _max_limit_ means maximum (hard) limit.
3405 # 
3406 # If _max_limit_ is not given, _cur_limit_ is used.
3407 # 
3408 # _resource_ indicates the kind of resource to limit.
3409 # It should be a symbol such as <code>:CORE</code>,
3410 # a string such as <code>"CORE"</code> or
3411 # a constant such as <code>Process::RLIMIT_CORE</code>.
3412 # The available resources are OS dependent.
3413 # Ruby may support following resources.
3414 # 
3415 # [AS] total available memory (bytes) (SUSv3, NetBSD, FreeBSD, OpenBSD but 4.4BSD-Lite)
3416 # [CORE] core size (bytes) (SUSv3)
3417 # [CPU] CPU time (seconds) (SUSv3)
3418 # [DATA] data segment (bytes) (SUSv3)
3419 # [FSIZE] file size (bytes) (SUSv3)
3420 # [MEMLOCK] total size for mlock(2) (bytes) (4.4BSD, GNU/Linux)
3421 # [MSGQUEUE] allocation for POSIX message queues (bytes) (GNU/Linux)
3422 # [NICE] ceiling on process's nice(2) value (number) (GNU/Linux)
3423 # [NOFILE] file descriptors (number) (SUSv3)
3424 # [NPROC] number of processes for the user (number) (4.4BSD, GNU/Linux)
3425 # [RSS] resident memory size (bytes) (4.2BSD, GNU/Linux)
3426 # [RTPRIO] ceiling on the process's real-time priority (number) (GNU/Linux)
3427 # [RTTIME] CPU time for real-time process (us) (GNU/Linux)
3428 # [SBSIZE] all socket buffers (bytes) (NetBSD, FreeBSD)
3429 # [SIGPENDING] number of queued signals allowed (signals) (GNU/Linux)
3430 # [STACK] stack size (bytes) (SUSv3)
3431 # 
3432 # _cur_limit_ and _max_limit_ may be
3433 # <code>:INFINITY</code>, <code>"INFINITY"</code> or
3434 # <code>Process::RLIM_INFINITY</code>,
3435 # which means that the resource is not limited.
3436 # They may be <code>Process::RLIM_SAVED_MAX</code>,
3437 # <code>Process::RLIM_SAVED_CUR</code> and
3438 # corresponding symbols and strings too.
3439 # See system setrlimit(2) manual for details.
3440 # 
3441 # The following example raises the soft limit of core size to
3442 # the hard limit to try to make core dump possible.
3443 # 
3444 #   Process.setrlimit(:CORE, Process.getrlimit(:CORE)[1])
3445 def self.setrlimit(resource, cur_limit, max_limit); end
3446 ##
3447 # Returns the (real) user ID of this process.
3448 # 
3449 #    Process.uid   #=> 501
3450 def self.uid; 0; end
3451 ##
3452 # Returns the (real) user ID of this process.
3453 # 
3454 #    Process.uid   #=> 501
3455 def self.rid; 0; end
3456 ##
3457 # Returns the (real) user ID of this process.
3458 # 
3459 #    Process.uid   #=> 501
3460 def self.getuid; 0; end
3461 ##
3462 # Sets the (user) user ID for this process. Not available on all
3463 # platforms.
3464 def self.uid= user; 0; end
3465 ##
3466 # Returns the (real) group ID for this process.
3467 # 
3468 #    Process.gid   #=> 500
3469 def self.gid; 0; end
3470 ##
3471 # Returns the (real) group ID for this process.
3472 # 
3473 #    Process.gid   #=> 500
3474 def self.getgid; 0; end
3475 ##
3476 # Sets the group ID for this process.
3477 def self.gid= fixnum; 0; end
3478 ##
3479 # Returns the effective user ID for this process.
3480 # 
3481 #    Process.euid   #=> 501
3482 def self.euid; 0; end
3483 ##
3484 # Returns the effective user ID for this process.
3485 # 
3486 #    Process.euid   #=> 501
3487 def self.eid; 0; end
3488 ##
3489 # Returns the effective user ID for this process.
3490 # 
3491 #    Process.euid   #=> 501
3492 def self.geteuid; 0; end
3493 ##
3494 # Sets the effective user ID for this process. Not available on all
3495 # platforms.
3496 def self.euid= user; end
3497 ##
3498 # Returns the effective group ID for this process. Not available on
3499 # all platforms.
3500 # 
3501 #    Process.egid   #=> 500
3502 def self.egid; 0; end
3503 ##
3504 # Returns the effective group ID for this process. Not available on
3505 # all platforms.
3506 # 
3507 #    Process.egid   #=> 500
3508 def self.geteid; 0; end
3509 ##
3510 # Sets the effective group ID for this process. Not available on all
3511 # platforms.
3512 def self.egid= fixnum; 0; end
3513 ##
3514 # Initializes the supplemental group access list by reading the
3515 # system group database and using all groups of which the given user
3516 # is a member. The group with the specified <em>gid</em> is also
3517 # added to the list. Returns the resulting <code>Array</code> of the
3518 # gids of all the groups in the supplementary group access list. Not
3519 # available on all platforms.
3520 # 
3521 #    Process.groups   #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
3522 #    Process.initgroups( "mgranger", 30 )   #=> [30, 6, 10, 11]
3523 #    Process.groups   #=> [30, 6, 10, 11]
3524 def self.initgroups(username, gid); []; end
3525 ##
3526 # Get an <code>Array</code> of the gids of groups in the
3527 # supplemental group access list for this process.
3528 # 
3529 #    Process.groups   #=> [27, 6, 10, 11]
3530 def self.groups; []; end
3531 ##
3532 # Set the supplemental group access list to the given
3533 # <code>Array</code> of group IDs.
3534 # 
3535 #    Process.groups   #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
3536 #    Process.groups = [27, 6, 10, 11]   #=> [27, 6, 10, 11]
3537 #    Process.groups   #=> [27, 6, 10, 11]
3538 def self.groups= array; []; end
3539 ##
3540 # Returns the maximum number of gids allowed in the supplemental
3541 # group access list.
3542 # 
3543 #    Process.maxgroups   #=> 32
3544 def self.maxgroups; 0; end
3545 ##
3546 # Sets the maximum number of gids allowed in the supplemental group
3547 # access list.
3548 def self.maxgroups= fixnum; 0; end
3549 ##
3550 # Detach the process from controlling terminal and run in
3551 # the background as system daemon.  Unless the argument
3552 # nochdir is true (i.e. non false), it changes the current
3553 # working directory to the root ("/"). Unless the argument
3554 # noclose is true, daemon() will redirect standard input,
3555 # standard output and standard error to /dev/null.
3556 # Return zero on success, or raise one of Errno::*.
3557 def self.daemon(); 0; end
3558 ##
3559 # Returns a <code>Tms</code> structure (see <code>Struct::Tms</code>)
3560 # that contains user and system CPU times for this process,
3561 # and also for children processes.
3562 # 
3563 #    t = Process.times
3564 #    [ t.utime, t.stime, t.cutime, t.cstime ]   #=> [0.0, 0.02, 0.00, 0.00]
3565 def self.times; Struct::Tms.new; end
3566 end
3567 
3568 ##
3569 # Many operating systems allow signals to be sent to running
3570 # processes. Some signals have a defined effect on the process, while
3571 # others may be trapped at the code level and acted upon. For
3572 # example, your process may trap the USR1 signal and use it to toggle
3573 # debugging, and may use TERM to initiate a controlled shutdown.
3574 # 
3575 #     pid = fork do
3576 #       Signal.trap("USR1") do
3577 #         $debug = !$debug
3578 #         puts "Debug now: #$debug"
3579 #       end
3580 #       Signal.trap("TERM") do
3581 #         puts "Terminating..."
3582 #         shutdown()
3583 #       end
3584 #       # . . . do some work . . .
3585 #     end
3586 # 
3587 #     Process.detach(pid)
3588 # 
3589 #     # Controlling program:
3590 #     Process.kill("USR1", pid)
3591 #     # ...
3592 #     Process.kill("USR1", pid)
3593 #     # ...
3594 #     Process.kill("TERM", pid)
3595 # 
3596 # produces:
3597 #     Debug now: true
3598 #     Debug now: false
3599 #    Terminating...
3600 # 
3601 # The list of available signal names and their interpretation is
3602 # system dependent. Signal delivery semantics may also vary between
3603 # systems; in particular signal delivery may not always be reliable.
3604 module Signal
3605 ##
3606 # Specifies the handling of signals. The first parameter is a signal
3607 # name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
3608 # signal number. The characters ``SIG'' may be omitted from the
3609 # signal name. The command or block specifies code to be run when the
3610 # signal is raised.
3611 # If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
3612 # will be ignored.
3613 # If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
3614 # will be invoked.
3615 # If the command is ``EXIT'', the script will be terminated by the signal.
3616 # If the command is ``SYSTEM_DEFAULT'', the operating system's default
3617 # handler will be invoked.
3618 # Otherwise, the given command or block will be run.
3619 # The special signal name ``EXIT'' or signal number zero will be
3620 # invoked just prior to program termination.
3621 # trap returns the previous handler for the given signal.
3622 # 
3623 #     Signal.trap(0, proc { puts "Terminating: #{$$}" })
3624 #     Signal.trap("CLD")  { puts "Child died" }
3625 #     fork && Process.wait
3626 # 
3627 # produces:
3628 #     Terminating: 27461
3629 #     Child died
3630 #     Terminating: 27460
3631 def self.trap( signal, command ); Object.new; end
3632 ##
3633 # Returns a list of signal names mapped to the corresponding
3634 # underlying signal numbers.
3635 # 
3636 #   Signal.list   #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
3637 def self.list; {}; end
3638 ##
3639 # convert signal number to signal name
3640 # 
3641 #    Signal.trap("INT") { |signo| puts Signal.signame(signo) }
3642 #    Process.kill("INT", 0)
3643 # 
3644 # <em>produces:</em>
3645 # 
3646 #    INT
3647 def self.signame(signo); ''; end
3648 end
3649 
3650 module Enumerable
3651 ##
3652 # Returns a lazy enumerator, whose methods map/collect,
3653 # flat_map/collect_concat, select/find_all, reject, grep, zip, take,
3654 # take_while, drop, drop_while, and cycle enumerate values only on an
3655 # as-needed basis.  However, if a block is given to zip or cycle, values
3656 # are enumerated immediately.
3657 # 
3658 # === Example
3659 # 
3660 # The following program finds pythagorean triples:
3661 # 
3662 #   def pythagorean_triples
3663 #     (1..Float::INFINITY).lazy.flat_map {|z|
3664 #       (1..z).flat_map {|x|
3665 #         (x..z).select {|y|
3666 #           x**2 + y**2 == z**2
3667 #         }.map {|y|
3668 #           [x, y, z]
3669 #         }
3670 #       }
3671 #     }
3672 #   end
3673 #   # show first ten pythagorean triples
3674 #   p pythagorean_triples.take(10).force # take is lazy, so force is needed
3675 #   p pythagorean_triples.first(10)      # first is eager
3676 #   # show pythagorean triples less than 100
3677 #   p pythagorean_triples.take_while { |*, z| z < 100 }.force
3678 def lazy; Enumerator::Lazy.new; end
3679 ##
3680 # Returns an array containing the items in <i>enum</i>.
3681 # 
3682 #    (1..7).to_a                       #=> [1, 2, 3, 4, 5, 6, 7]
3683 #    { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a   #=> [["a", 1], ["b", 2], ["c", 3]]
3684 def to_a; []; end
3685 ##
3686 # Returns an array containing the items in <i>enum</i>.
3687 # 
3688 #    (1..7).to_a                       #=> [1, 2, 3, 4, 5, 6, 7]
3689 #    { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a   #=> [["a", 1], ["b", 2], ["c", 3]]
3690 def entries; []; end
3691 ##
3692 # Returns an array containing the items in <i>enum</i> sorted,
3693 # either according to their own <code><=></code> method, or by using
3694 # the results of the supplied block. The block should return -1, 0, or
3695 # +1 depending on the comparison between <i>a</i> and <i>b</i>. As of
3696 # Ruby 1.8, the method <code>Enumerable#sort_by</code> implements a
3697 # built-in Schwartzian Transform, useful when key computation or
3698 # comparison is expensive.
3699 # 
3700 #    %w(rhea kea flea).sort          #=> ["flea", "kea", "rhea"]
3701 #    (1..10).sort { |a, b| b <=> a }  #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
3702 def sort; []; end
3703 ##
3704 # Sorts <i>enum</i> using a set of keys generated by mapping the
3705 # values in <i>enum</i> through the given block.
3706 # 
3707 # If no block is given, an enumerator is returned instead.
3708 # 
3709 #    %w{apple pear fig}.sort_by { |word| word.length}
3710 #                  #=> ["fig", "pear", "apple"]
3711 # 
3712 # The current implementation of <code>sort_by</code> generates an
3713 # array of tuples containing the original collection element and the
3714 # mapped value. This makes <code>sort_by</code> fairly expensive when
3715 # the keysets are simple.
3716 # 
3717 #    require 'benchmark'
3718 # 
3719 #    a = (1..100000).map { rand(100000) }
3720 # 
3721 #    Benchmark.bm(10) do |b|
3722 #      b.report("Sort")    { a.sort }
3723 #      b.report("Sort by") { a.sort_by { |a| a } }
3724 #    end
3725 # 
3726 # <em>produces:</em>
3727 # 
3728 #    user     system      total        real
3729 #    Sort        0.180000   0.000000   0.180000 (  0.175469)
3730 #    Sort by     1.980000   0.040000   2.020000 (  2.013586)
3731 # 
3732 # However, consider the case where comparing the keys is a non-trivial
3733 # operation. The following code sorts some files on modification time
3734 # using the basic <code>sort</code> method.
3735 # 
3736 #    files = Dir["*"]
3737 #    sorted = files.sort { |a, b| File.new(a).mtime <=> File.new(b).mtime }
3738 #    sorted   #=> ["mon", "tues", "wed", "thurs"]
3739 # 
3740 # This sort is inefficient: it generates two new <code>File</code>
3741 # objects during every comparison. A slightly better technique is to
3742 # use the <code>Kernel#test</code> method to generate the modification
3743 # times directly.
3744 # 
3745 #    files = Dir["*"]
3746 #    sorted = files.sort { |a, b|
3747 #      test(?M, a) <=> test(?M, b)
3748 #    }
3749 #    sorted   #=> ["mon", "tues", "wed", "thurs"]
3750 # 
3751 # This still generates many unnecessary <code>Time</code> objects. A
3752 # more efficient technique is to cache the sort keys (modification
3753 # times in this case) before the sort. Perl users often call this
3754 # approach a Schwartzian Transform, after Randal Schwartz. We
3755 # construct a temporary array, where each element is an array
3756 # containing our sort key along with the filename. We sort this array,
3757 # and then extract the filename from the result.
3758 # 
3759 #    sorted = Dir["*"].collect { |f|
3760 #       [test(?M, f), f]
3761 #    }.sort.collect { |f| f[1] }
3762 #    sorted   #=> ["mon", "tues", "wed", "thurs"]
3763 # 
3764 # This is exactly what <code>sort_by</code> does internally.
3765 # 
3766 #    sorted = Dir["*"].sort_by { |f| test(?M, f) }
3767 #    sorted   #=> ["mon", "tues", "wed", "thurs"]
3768 def sort_by(&block); Enumerator.new; end
3769 ##
3770 # Returns an array of every element in <i>enum</i> for which
3771 # <code>Pattern === element</code>. If the optional <em>block</em> is
3772 # supplied, each matching element is passed to it, and the block's
3773 # result is stored in the output array.
3774 # 
3775 #    (1..100).grep 38..44   #=> [38, 39, 40, 41, 42, 43, 44]
3776 #    c = IO.constants
3777 #    c.grep(/SEEK/)         #=> [:SEEK_SET, :SEEK_CUR, :SEEK_END]
3778 #    res = c.grep(/SEEK/) { |v| IO.const_get(v) }
3779 #    res                    #=> [0, 1, 2]
3780 def grep(pattern); []; end
3781 ##
3782 # Returns the number of items in +enum+ through enumeration.
3783 # If an argument is given, the number of items in +enum+ that
3784 # are equal to +item+ are counted.  If a block is given, it
3785 # counts the number of elements yielding a true value.
3786 # 
3787 #    ary = [1, 2, 4, 2]
3788 #    ary.count               #=> 4
3789 #    ary.count(2)            #=> 2
3790 #    ary.count{ |x| x%2==0 } #=> 3
3791 def count; 0; end
3792 ##
3793 # Passes each entry in <i>enum</i> to <em>block</em>. Returns the
3794 # first for which <em>block</em> is not false.  If no
3795 # object matches, calls <i>ifnone</i> and returns its result when it
3796 # is specified, or returns <code>nil</code> otherwise.
3797 # 
3798 # If no block is given, an enumerator is returned instead.
3799 # 
3800 #    (1..10).detect  { |i| i % 5 == 0 and i % 7 == 0 }   #=> nil
3801 #    (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 }   #=> 35
3802 def detect(ifnone = null, &block); Enumerator.new; end
3803 ##
3804 # Passes each entry in <i>enum</i> to <em>block</em>. Returns the
3805 # first for which <em>block</em> is not false.  If no
3806 # object matches, calls <i>ifnone</i> and returns its result when it
3807 # is specified, or returns <code>nil</code> otherwise.
3808 # 
3809 # If no block is given, an enumerator is returned instead.
3810 # 
3811 #    (1..10).detect  { |i| i % 5 == 0 and i % 7 == 0 }   #=> nil
3812 #    (1..100).detect { |i| i % 5 == 0 and i % 7 == 0 }   #=> 35
3813 def find(ifnone = null, &block); Enumerator.new; end
3814 ##
3815 # Compares each entry in <i>enum</i> with <em>value</em> or passes
3816 # to <em>block</em>.  Returns the index for the first for which the
3817 # evaluated value is non-false.  If no object matches, returns
3818 # <code>nil</code>
3819 # 
3820 # If neither block nor argument is given, an enumerator is returned instead.
3821 # 
3822 #    (1..10).find_index  { |i| i % 5 == 0 and i % 7 == 0 }  #=> nil
3823 #    (1..100).find_index { |i| i % 5 == 0 and i % 7 == 0 }  #=> 34
3824 #    (1..100).find_index(50)                                #=> 49
3825 def find_index(value); Enumerator.new; end
3826 ##
3827 # Returns an array containing all elements of +enum+
3828 # for which the given +block+ returns a true value.
3829 # 
3830 # If no block is given, an Enumerator is returned instead.
3831 # 
3832 #    (1..10).find_all { |i|  i % 3 == 0 }   #=> [3, 6, 9]
3833 # 
3834 #    [1,2,3,4,5].select { |num|  num.even?  }   #=> [2, 4]
3835 # 
3836 # See also Enumerable#reject.
3837 def find_all(&block); Enumerator.new; end
3838 ##
3839 # Returns an array containing all elements of +enum+
3840 # for which the given +block+ returns a true value.
3841 # 
3842 # If no block is given, an Enumerator is returned instead.
3843 # 
3844 #    (1..10).find_all { |i|  i % 3 == 0 }   #=> [3, 6, 9]
3845 # 
3846 #    [1,2,3,4,5].select { |num|  num.even?  }   #=> [2, 4]
3847 # 
3848 # See also Enumerable#reject.
3849 def select(&block); Enumerator.new; end
3850 ##
3851 # Returns an array for all elements of +enum+ for which the given
3852 # +block+ returns false.
3853 # 
3854 # If no block is given, an Enumerator is returned instead.
3855 # 
3856 #    (1..10).reject { |i|  i % 3 == 0 }   #=> [1, 2, 4, 5, 7, 8, 10]
3857 # 
3858 #    [1, 2, 3, 4, 5].reject { |num| num.even? } #=> [1, 3, 5]
3859 # 
3860 # See also Enumerable#find_all.
3861 def reject(&block); Enumerator.new; end
3862 ##
3863 # Returns a new array with the results of running <em>block</em> once
3864 # for every element in <i>enum</i>.
3865 # 
3866 # If no block is given, an enumerator is returned instead.
3867 # 
3868 #    (1..4).collect { |i| i*i }  #=> [1, 4, 9, 16]
3869 #    (1..4).collect { "cat"  }   #=> ["cat", "cat", "cat", "cat"]
3870 def collect(&block); Enumerator.new; end
3871 ##
3872 # Returns a new array with the results of running <em>block</em> once
3873 # for every element in <i>enum</i>.
3874 # 
3875 # If no block is given, an enumerator is returned instead.
3876 # 
3877 #    (1..4).collect { |i| i*i }  #=> [1, 4, 9, 16]
3878 #    (1..4).collect { "cat"  }   #=> ["cat", "cat", "cat", "cat"]
3879 def map(&block); Enumerator.new; end
3880 ##
3881 # Returns a new array with the concatenated results of running
3882 # <em>block</em> once for every element in <i>enum</i>.
3883 # 
3884 # If no block is given, an enumerator is returned instead.
3885 # 
3886 #    [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4]
3887 #    [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100]
3888 def flat_map(&block); Enumerator.new; end
3889 ##
3890 # Returns a new array with the concatenated results of running
3891 # <em>block</em> once for every element in <i>enum</i>.
3892 # 
3893 # If no block is given, an enumerator is returned instead.
3894 # 
3895 #    [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4]
3896 #    [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100]
3897 def collect_concat(&block); Enumerator.new; end
3898 ##
3899 # Combines all elements of <i>enum</i> by applying a binary
3900 # operation, specified by a block or a symbol that names a
3901 # method or operator.
3902 # 
3903 # If you specify a block, then for each element in <i>enum</i>
3904 # the block is passed an accumulator value (<i>memo</i>) and the element.
3905 # If you specify a symbol instead, then each element in the collection
3906 # will be passed to the named method of <i>memo</i>.
3907 # In either case, the result becomes the new value for <i>memo</i>.
3908 # At the end of the iteration, the final value of <i>memo</i> is the
3909 # return value for the method.
3910 # 
3911 # If you do not explicitly specify an <i>initial</i> value for <i>memo</i>,
3912 # then the first element of collection is used as the initial value
3913 # of <i>memo</i>.
3914 # 
3915 #    # Sum some numbers
3916 #    (5..10).reduce(:+)                             #=> 45
3917 #    # Same using a block and inject
3918 #    (5..10).inject { |sum, n| sum + n }            #=> 45
3919 #    # Multiply some numbers
3920 #    (5..10).reduce(1, :*)                          #=> 151200
3921 #    # Same using a block
3922 #    (5..10).inject(1) { |product, n| product * n } #=> 151200
3923 #    # find the longest word
3924 #    longest = %w{ cat sheep bear }.inject do |memo, word|
3925 #       memo.length > word.length ? memo : word
3926 #    end
3927 #    longest                                        #=> "sheep"
3928 def inject(initial, sym); Object.new; end
3929 ##
3930 # Combines all elements of <i>enum</i> by applying a binary
3931 # operation, specified by a block or a symbol that names a
3932 # method or operator.
3933 # 
3934 # If you specify a block, then for each element in <i>enum</i>
3935 # the block is passed an accumulator value (<i>memo</i>) and the element.
3936 # If you specify a symbol instead, then each element in the collection
3937 # will be passed to the named method of <i>memo</i>.
3938 # In either case, the result becomes the new value for <i>memo</i>.
3939 # At the end of the iteration, the final value of <i>memo</i> is the
3940 # return value for the method.
3941 # 
3942 # If you do not explicitly specify an <i>initial</i> value for <i>memo</i>,
3943 # then the first element of collection is used as the initial value
3944 # of <i>memo</i>.
3945 # 
3946 #    # Sum some numbers
3947 #    (5..10).reduce(:+)                             #=> 45
3948 #    # Same using a block and inject
3949 #    (5..10).inject { |sum, n| sum + n }            #=> 45
3950 #    # Multiply some numbers
3951 #    (5..10).reduce(1, :*)                          #=> 151200
3952 #    # Same using a block
3953 #    (5..10).inject(1) { |product, n| product * n } #=> 151200
3954 #    # find the longest word
3955 #    longest = %w{ cat sheep bear }.inject do |memo, word|
3956 #       memo.length > word.length ? memo : word
3957 #    end
3958 #    longest                                        #=> "sheep"
3959 def reduce(initial, sym); Object.new; end
3960 ##
3961 # Returns two arrays, the first containing the elements of
3962 # <i>enum</i> for which the block evaluates to true, the second
3963 # containing the rest.
3964 # 
3965 # If no block is given, an enumerator is returned instead.
3966 # 
3967 #    (1..6).partition { |v| v.even? }  #=> [[2, 4, 6], [1, 3, 5]]
3968 def partition(&block); Enumerator.new; end
3969 ##
3970 # Groups the collection by result of the block.  Returns a hash where the
3971 # keys are the evaluated result from the block and the values are
3972 # arrays of elements in the collection that correspond to the key.
3973 # 
3974 # If no block is given an enumerator is returned.
3975 # 
3976 #    (1..6).group_by { |i| i%3 }   #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
3977 def group_by(&block); Enumerator.new; end
3978 ##
3979 # Returns the first element, or the first +n+ elements, of the enumerable.
3980 # If the enumerable is empty, the first form returns <code>nil</code>, and the
3981 # second form returns an empty array.
3982 # 
3983 #   %w[foo bar baz].first     #=> "foo"
3984 #   %w[foo bar baz].first(2)  #=> ["foo", "bar"]
3985 #   %w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
3986 #   [].first                  #=> nil
3987 def first; []; end
3988 ##
3989 # Passes each element of the collection to the given block. The method
3990 # returns <code>true</code> if the block never returns
3991 # <code>false</code> or <code>nil</code>. If the block is not given,
3992 # Ruby adds an implicit block of <code>{ |obj| obj }</code> which will
3993 # cause #all? to return +true+ when none of the collection members are
3994 # +false+ or +nil+.
3995 # 
3996 #    %w[ant bear cat].all? { |word| word.length >= 3 } #=> true
3997 #    %w[ant bear cat].all? { |word| word.length >= 4 } #=> false
3998 #    [nil, true, 99].all?                              #=> false
3999 def all?; true || false; end
4000 ##
4001 # Passes each element of the collection to the given block. The method
4002 # returns <code>true</code> if the block ever returns a value other
4003 # than <code>false</code> or <code>nil</code>. If the block is not
4004 # given, Ruby adds an implicit block of <code>{ |obj| obj }</code> that
4005 # will cause #any? to return +true+ if at least one of the collection
4006 # members is not +false+ or +nil+.
4007 # 
4008 #    %w[ant bear cat].any? { |word| word.length >= 3 } #=> true
4009 #    %w[ant bear cat].any? { |word| word.length >= 4 } #=> true
4010 #    [nil, true, 99].any?                              #=> true
4011 def any?; true || false; end
4012 ##
4013 # Passes each element of the collection to the given block. The method
4014 # returns <code>true</code> if the block returns <code>true</code>
4015 # exactly once. If the block is not given, <code>one?</code> will return
4016 # <code>true</code> only if exactly one of the collection members is
4017 # true.
4018 # 
4019 #    %w{ant bear cat}.one? { |word| word.length == 4 }  #=> true
4020 #    %w{ant bear cat}.one? { |word| word.length > 4 }   #=> false
4021 #    %w{ant bear cat}.one? { |word| word.length < 4 }   #=> false
4022 #    [ nil, true, 99 ].one?                             #=> false
4023 #    [ nil, true, false ].one?                          #=> true
4024 def one?; true || false; end
4025 ##
4026 # Passes each element of the collection to the given block. The method
4027 # returns <code>true</code> if the block never returns <code>true</code>
4028 # for all elements. If the block is not given, <code>none?</code> will return
4029 # <code>true</code> only if none of the collection members is true.
4030 # 
4031 #    %w{ant bear cat}.none? { |word| word.length == 5 } #=> true
4032 #    %w{ant bear cat}.none? { |word| word.length >= 4 } #=> false
4033 #    [].none?                                           #=> true
4034 #    [nil].none?                                        #=> true
4035 #    [nil, false].none?                                 #=> true
4036 def none?; true || false; end
4037 ##
4038 # Returns the object in <i>enum</i> with the minimum value. The
4039 # first form assumes all objects implement <code>Comparable</code>;
4040 # the second uses the block to return <em>a <=> b</em>.
4041 # 
4042 #    a = %w(albatross dog horse)
4043 #    a.min                                   #=> "albatross"
4044 #    a.min { |a, b| a.length <=> b.length }  #=> "dog"
4045 def min; Object.new; end
4046 ##
4047 # Returns the object in _enum_ with the maximum value. The
4048 # first form assumes all objects implement <code>Comparable</code>;
4049 # the second uses the block to return <em>a <=> b</em>.
4050 # 
4051 #    a = %w(albatross dog horse)
4052 #    a.max                                   #=> "horse"
4053 #    a.max { |a, b| a.length <=> b.length }  #=> "albatross"
4054 def max; Object.new; end
4055 ##
4056 # Returns two elements array which contains the minimum and the
4057 # maximum value in the enumerable.  The first form assumes all
4058 # objects implement <code>Comparable</code>; the second uses the
4059 # block to return <em>a <=> b</em>.
4060 # 
4061 #    a = %w(albatross dog horse)
4062 #    a.minmax                                  #=> ["albatross", "horse"]
4063 #    a.minmax { |a, b| a.length <=> b.length } #=> ["dog", "albatross"]
4064 def minmax; []; end
4065 ##
4066 # Returns the object in <i>enum</i> that gives the minimum
4067 # value from the given block.
4068 # 
4069 # If no block is given, an enumerator is returned instead.
4070 # 
4071 #    a = %w(albatross dog horse)
4072 #    a.min_by { |x| x.length }   #=> "dog"
4073 def min_by(&block); Enumerator.new; end
4074 ##
4075 # Returns the object in <i>enum</i> that gives the maximum
4076 # value from the given block.
4077 # 
4078 # If no block is given, an enumerator is returned instead.
4079 # 
4080 #    a = %w(albatross dog horse)
4081 #    a.max_by { |x| x.length }   #=> "albatross"
4082 def max_by(&block); Enumerator.new; end
4083 ##
4084 # Returns a two element array containing the objects in
4085 # <i>enum</i> that correspond to the minimum and maximum values respectively
4086 # from the given block.
4087 # 
4088 # If no block is given, an enumerator is returned instead.
4089 # 
4090 #    a = %w(albatross dog horse)
4091 #    a.minmax_by { |x| x.length }   #=> ["dog", "albatross"]
4092 def minmax_by(&block); Enumerator.new; end
4093 ##
4094 # Returns <code>true</code> if any member of <i>enum</i> equals
4095 # <i>obj</i>. Equality is tested using <code>==</code>.
4096 # 
4097 #    IO.constants.include? :SEEK_SET          #=> true
4098 #    IO.constants.include? :SEEK_NO_FURTHER   #=> false
4099 def include?(obj); true || false; end
4100 ##
4101 # Returns <code>true</code> if any member of <i>enum</i> equals
4102 # <i>obj</i>. Equality is tested using <code>==</code>.
4103 # 
4104 #    IO.constants.include? :SEEK_SET          #=> true
4105 #    IO.constants.include? :SEEK_NO_FURTHER   #=> false
4106 def member?(obj); true || false; end
4107 ##
4108 # Calls <em>block</em> with two arguments, the item and its index,
4109 # for each item in <i>enum</i>.  Given arguments are passed through
4110 # to #each().
4111 # 
4112 # If no block is given, an enumerator is returned instead.
4113 # 
4114 #    hash = Hash.new
4115 #    %w(cat dog wombat).each_with_index { |item, index|
4116 #      hash[item] = index
4117 #    }
4118 #    hash   #=> {"cat"=>0, "dog"=>1, "wombat"=>2}
4119 def each_with_index(); Enumerator.new; end
4120 ##
4121 # Builds a temporary array and traverses that array in reverse order.
4122 # 
4123 # If no block is given, an enumerator is returned instead.
4124 # 
4125 #     (1..3).reverse_each { |v| p v }
4126 # 
4127 #   produces:
4128 # 
4129 #     3
4130 #     2
4131 #     1
4132 def reverse_each(); Enumerator.new; end
4133 ##
4134 # Calls <i>block</i> once for each element in +self+, passing that
4135 # element as a parameter, converting multiple values from yield to an
4136 # array.
4137 # 
4138 # If no block is given, an enumerator is returned instead.
4139 # 
4140 #    class Foo
4141 #      include Enumerable
4142 #      def each
4143 #        yield 1
4144 #        yield 1, 2
4145 #        yield
4146 #      end
4147 #    end
4148 #    Foo.new.each_entry{ |o| p o }
4149 # 
4150 # produces:
4151 # 
4152 #    1
4153 #    [1, 2]
4154 #    nil
4155 def each_entry(&block); Enumerator.new; end
4156 ##
4157 # Iterates the given block for each slice of <n> elements.  If no
4158 # block is given, returns an enumerator.
4159 # 
4160 #     (1..10).each_slice(3) { |a| p a }
4161 #     # outputs below
4162 #     [1, 2, 3]
4163 #     [4, 5, 6]
4164 #     [7, 8, 9]
4165 #     [10]
4166 def each_slice(n, &block); Enumerator.new; end
4167 ##
4168 # Iterates the given block for each array of consecutive <n>
4169 # elements.  If no block is given, returns an enumerator.
4170 # 
4171 # e.g.:
4172 #     (1..10).each_cons(3) { |a| p a }
4173 #     # outputs below
4174 #     [1, 2, 3]
4175 #     [2, 3, 4]
4176 #     [3, 4, 5]
4177 #     [4, 5, 6]
4178 #     [5, 6, 7]
4179 #     [6, 7, 8]
4180 #     [7, 8, 9]
4181 #     [8, 9, 10]
4182 def each_cons(n, &block); Enumerator.new; end
4183 ##
4184 # Iterates the given block for each element with an arbitrary
4185 # object given, and returns the initially given object.
4186 # 
4187 # If no block is given, returns an enumerator.
4188 # 
4189 #     evens = (1..10).each_with_object([]) { |i, a| a << i*2 }
4190 #     #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
4191 def each_with_object(obj, &block); Enumerator.new; end
4192 ##
4193 # Takes one element from <i>enum</i> and merges corresponding
4194 # elements from each <i>args</i>.  This generates a sequence of
4195 # <em>n</em>-element arrays, where <em>n</em> is one more than the
4196 # count of arguments.  The length of the resulting sequence will be
4197 # <code>enum#size</code>.  If the size of any argument is less than
4198 # <code>enum#size</code>, <code>nil</code> values are supplied. If
4199 # a block is given, it is invoked for each output array, otherwise
4200 # an array of arrays is returned.
4201 # 
4202 #    a = [ 4, 5, 6 ]
4203 #    b = [ 7, 8, 9 ]
4204 # 
4205 #    [1, 2, 3].zip(a, b)      #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
4206 #    [1, 2].zip(a, b)         #=> [[1, 4, 7], [2, 5, 8]]
4207 #    a.zip([1, 2], [8])       #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
4208 def zip(); end
4209 ##
4210 # Returns first n elements from <i>enum</i>.
4211 # 
4212 #    a = [1, 2, 3, 4, 5, 0]
4213 #    a.take(3)             #=> [1, 2, 3]
4214 def take(n); []; end
4215 ##
4216 # Passes elements to the block until the block returns +nil+ or +false+,
4217 # then stops iterating and returns an array of all prior elements.
4218 # 
4219 # If no block is given, an enumerator is returned instead.
4220 # 
4221 #    a = [1, 2, 3, 4, 5, 0]
4222 #    a.take_while { |i| i < 3 }   #=> [1, 2]
4223 def take_while(&block); Enumerator.new; end
4224 ##
4225 # Drops first n elements from <i>enum</i>, and returns rest elements
4226 # in an array.
4227 # 
4228 #    a = [1, 2, 3, 4, 5, 0]
4229 #    a.drop(3)             #=> [4, 5, 0]
4230 def drop(n); []; end
4231 ##
4232 # Drops elements up to, but not including, the first element for
4233 # which the block returns +nil+ or +false+ and returns an array
4234 # containing the remaining elements.
4235 # 
4236 # If no block is given, an enumerator is returned instead.
4237 # 
4238 #    a = [1, 2, 3, 4, 5, 0]
4239 #    a.drop_while { |i| i < 3 }   #=> [3, 4, 5, 0]
4240 def drop_while(&block); Enumerator.new; end
4241 ##
4242 # Calls <i>block</i> for each element of <i>enum</i> repeatedly _n_
4243 # times or forever if none or +nil+ is given.  If a non-positive
4244 # number is given or the collection is empty, does nothing.  Returns
4245 # +nil+ if the loop has finished without getting interrupted.
4246 # 
4247 # Enumerable#cycle saves elements in an internal array so changes
4248 # to <i>enum</i> after the first pass have no effect.
4249 # 
4250 # If no block is given, an enumerator is returned instead.
4251 # 
4252 #    a = ["a", "b", "c"]
4253 #    a.cycle { |x| puts x }  # print, a, b, c, a, b, c,.. forever.
4254 #    a.cycle(2) { |x| puts x }  # print, a, b, c, a, b, c.
4255 def cycle(n=null, &block); Enumerator.new; end
4256 ##
4257 # Enumerates over the items, chunking them together based on the return
4258 # value of the block.
4259 # 
4260 # Consecutive elements which return the same block value are chunked together.
4261 # 
4262 # For example, consecutive even numbers and odd numbers can be
4263 # chunked as follows.
4264 # 
4265 #   [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5].chunk { |n|
4266 #     n.even?
4267 #   }.each { |even, ary|
4268 #     p [even, ary]
4269 #   }
4270 #   #=> [false, [3, 1]]
4271 #   #   [true, [4]]
4272 #   #   [false, [1, 5, 9]]
4273 #   #   [true, [2, 6]]
4274 #   #   [false, [5, 3, 5]]
4275 # 
4276 # This method is especially useful for sorted series of elements.
4277 # The following example counts words for each initial letter.
4278 # 
4279 #   open("/usr/share/dict/words", "r:iso-8859-1") { |f|
4280 #     f.chunk { |line| line.ord }.each { |ch, lines| p [ch.chr, lines.length] }
4281 #   }
4282 #   #=> ["\n", 1]
4283 #   #   ["A", 1327]
4284 #   #   ["B", 1372]
4285 #   #   ["C", 1507]
4286 #   #   ["D", 791]
4287 #   #   ...
4288 # 
4289 # The following key values have special meaning:
4290 # - +nil+ and +:_separator+ specifies that the elements should be dropped.
4291 # - +:_alone+ specifies that the element should be chunked by itself.
4292 # 
4293 # Any other symbols that begin with an underscore will raise an error:
4294 # 
4295 #   items.chunk { |item| :_underscore }
4296 #   #=> RuntimeError: symbol begins with an underscore is reserved
4297 # 
4298 # +nil+ and +:_separator+ can be used to ignore some elements.
4299 # 
4300 # For example, the sequence of hyphens in svn log can be eliminated as follows:
4301 # 
4302 #   sep = "-"*72 + "\n"
4303 #   IO.popen("svn log README") { |f|
4304 #     f.chunk { |line|
4305 #       line != sep || nil
4306 #     }.each { |_, lines|
4307 #       pp lines
4308 #     }
4309 #   }
4310 #   #=> ["r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n",
4311 #   #    "\n",
4312 #   #    "* README, README.ja: Update the portability section.\n",
4313 #   #    "\n"]
4314 #   #   ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n",
4315 #   #    "\n",
4316 #   #    "* README, README.ja: Add a note about default C flags.\n",
4317 #   #    "\n"]
4318 #   #   ...
4319 # 
4320 # Paragraphs separated by empty lines can be parsed as follows:
4321 # 
4322 #   File.foreach("README").chunk { |line|
4323 #     /\A\s*\z/ !~ line || nil
4324 #   }.each { |_, lines|
4325 #     pp lines
4326 #   }
4327 # 
4328 # +:_alone+ can be used to force items into their own chunk.
4329 # For example, you can put lines that contain a URL by themselves,
4330 # and chunk the rest of the lines together, like this:
4331 # 
4332 #   pattern = /http/
4333 #   open(filename) { |f|
4334 #     f.chunk { |line| line =~ pattern ? :_alone : true }.each { |key, lines|
4335 #       pp lines
4336 #     }
4337 #   }
4338 # 
4339 # If the block needs to maintain state over multiple elements,
4340 # an +initial_state+ argument can be used.
4341 # If a non-nil value is given,
4342 # a reference to it is passed as the 2nd argument of the block for the
4343 # +chunk+ method, so state-changes to it persist across block calls.
4344 def chunk(&block); Enumerator.new; end
4345 ##
4346 # Creates an enumerator for each chunked elements.
4347 # The beginnings of chunks are defined by _pattern_ and the block.
4348 # 
4349 # If <code>_pattern_ === _elt_</code> returns <code>true</code> or the block
4350 # returns <code>true</code> for the element, the element is beginning of a
4351 # chunk.
4352 # 
4353 # The <code>===</code> and _block_ is called from the first element to the last
4354 # element of _enum_.  The result for the first element is ignored.
4355 # 
4356 # The result enumerator yields the chunked elements as an array.
4357 # So +each+ method can be called as follows:
4358 # 
4359 #   enum.slice_before(pattern).each { |ary| ... }
4360 #   enum.slice_before { |elt| bool }.each { |ary| ... }
4361 #   enum.slice_before(initial_state) { |elt, state| bool }.each { |ary| ... }
4362 # 
4363 # Other methods of the Enumerator class and Enumerable module,
4364 # such as map, etc., are also usable.
4365 # 
4366 # For example, iteration over ChangeLog entries can be implemented as
4367 # follows:
4368 # 
4369 #   # iterate over ChangeLog entries.
4370 #   open("ChangeLog") { |f|
4371 #     f.slice_before(/\A\S/).each { |e| pp e }
4372 #   }
4373 # 
4374 #   # same as above.  block is used instead of pattern argument.
4375 #   open("ChangeLog") { |f|
4376 #     f.slice_before { |line| /\A\S/ === line }.each { |e| pp e }
4377 #   }
4378 # 
4379 # "svn proplist -R" produces multiline output for each file.
4380 # They can be chunked as follows:
4381 # 
4382 #   IO.popen([{"LC_ALL"=>"C"}, "svn", "proplist", "-R"]) { |f|
4383 #     f.lines.slice_before(/\AProp/).each { |lines| p lines }
4384 #   }
4385 #   #=> ["Properties on '.':\n", "  svn:ignore\n", "  svk:merge\n"]
4386 #   #   ["Properties on 'goruby.c':\n", "  svn:eol-style\n"]
4387 #   #   ["Properties on 'complex.c':\n", "  svn:mime-type\n", "  svn:eol-style\n"]
4388 #   #   ["Properties on 'regparse.c':\n", "  svn:eol-style\n"]
4389 #   #   ...
4390 # 
4391 # If the block needs to maintain state over multiple elements,
4392 # local variables can be used.
4393 # For example, three or more consecutive increasing numbers can be squashed
4394 # as follows:
4395 # 
4396 #   a = [0, 2, 3, 4, 6, 7, 9]
4397 #   prev = a[0]
4398 #   p a.slice_before { |e|
4399 #     prev, prev2 = e, prev
4400 #     prev2 + 1 != e
4401 #   }.map { |es|
4402 #     es.length <= 2 ? es.join(",") : "#{es.first}-#{es.last}"
4403 #   }.join(",")
4404 #   #=> "0,2-4,6,7,9"
4405 # 
4406 # However local variables are not appropriate to maintain state
4407 # if the result enumerator is used twice or more.
4408 # In such a case, the last state of the 1st +each+ is used in the 2nd +each+.
4409 # The _initial_state_ argument can be used to avoid this problem.
4410 # If non-nil value is given as _initial_state_,
4411 # it is duplicated for each +each+ method invocation of the enumerator.
4412 # The duplicated object is passed to 2nd argument of the block for
4413 # +slice_before+ method.
4414 # 
4415 #   # Word wrapping.  This assumes all characters have same width.
4416 #   def wordwrap(words, maxwidth)
4417 #     # if cols is a local variable, 2nd "each" may start with non-zero cols.
4418 #     words.slice_before(cols: 0) { |w, h|
4419 #       h[:cols] += 1 if h[:cols] != 0
4420 #       h[:cols] += w.length
4421 #       if maxwidth < h[:cols]
4422 #         h[:cols] = w.length
4423 #         true
4424 #       else
4425 #         false
4426 #       end
4427 #     }
4428 #   end
4429 #   text = (1..20).to_a.join(" ")
4430 #   enum = wordwrap(text.split(/\s+/), 10)
4431 #   puts "-"*10
4432 #   enum.each { |ws| puts ws.join(" ") }
4433 #   puts "-"*10
4434 #   #=> ----------
4435 #   #   1 2 3 4 5
4436 #   #   6 7 8 9 10
4437 #   #   11 12 13
4438 #   #   14 15 16
4439 #   #   17 18 19
4440 #   #   20
4441 #   #   ----------
4442 # 
4443 # mbox contains series of mails which start with Unix From line.
4444 # So each mail can be extracted by slice before Unix From line.
4445 # 
4446 #   # parse mbox
4447 #   open("mbox") { |f|
4448 #     f.slice_before { |line|
4449 #       line.start_with? "From "
4450 #     }.each { |mail|
4451 #       unix_from = mail.shift
4452 #       i = mail.index("\n")
4453 #       header = mail[0...i]
4454 #       body = mail[(i+1)..-1]
4455 #       body.pop if body.last == "\n"
4456 #       fields = header.slice_before { |line| !" \t".include?(line[0]) }.to_a
4457 #       p unix_from
4458 #       pp fields
4459 #       pp body
4460 #     }
4461 #   }
4462 # 
4463 #   # split mails in mbox (slice before Unix From line after an empty line)
4464 #   open("mbox") { |f|
4465 #     f.slice_before(emp: true) { |line, h|
4466 #       prevemp = h[:emp]
4467 #       h[:emp] = line == "\n"
4468 #       prevemp && line.start_with?("From ")
4469 #     }.each { |mail|
4470 #       mail.pop if mail.last == "\n"
4471 #       pp mail
4472 #     }
4473 #   }
4474 def slice_before(pattern); Enumerator.new; end
4475 end
4476 
4477 ##
4478 # Bignum objects hold integers outside the range of
4479 # Fixnum. Bignum objects are created
4480 # automatically when integer calculations would otherwise overflow a
4481 # Fixnum. When a calculation involving
4482 # Bignum objects returns a result that will fit in a
4483 # Fixnum, the result is automatically converted.
4484 # 
4485 # For the purposes of the bitwise operations and <code>[]</code>, a
4486 # Bignum is treated as if it were an infinite-length
4487 # bitstring with 2's complement representation.
4488 # 
4489 # While Fixnum values are immediate, Bignum
4490 # objects are not---assignment and parameter passing work with
4491 # references to objects, not the objects themselves.
4492 class Bignum < Integer
4493 ##
4494 # Returns a string containing the representation of <i>big</i> radix
4495 # <i>base</i> (2 through 36).
4496 # 
4497 #    12345654321.to_s         #=> "12345654321"
4498 #    12345654321.to_s(2)      #=> "1011011111110110111011110000110001"
4499 #    12345654321.to_s(8)      #=> "133766736061"
4500 #    12345654321.to_s(16)     #=> "2dfdbbc31"
4501 #    78546939656932.to_s(36)  #=> "rubyrules"
4502 def to_s(base=10); ''; end
4503 ##
4504 # Unary minus (returns an integer whose value is 0-big)
4505 def -@; 0; end
4506 ##
4507 # Adds big and other, returning the result.
4508 def +; 0; end
4509 ##
4510 # Subtracts other from big, returning the result.
4511 def -; 0; end
4512 ##
4513 # Multiplies big and other, returning the result.
4514 def *; 0; end
4515 ##
4516 # Performs division: the class of the resulting object depends on
4517 # the class of <code>numeric</code> and on the magnitude of the
4518 # result.
4519 def /; 0; end
4520 ##
4521 # Returns big modulo other. See Numeric.divmod for more
4522 # information.
4523 def %; 0; end
4524 ##
4525 # Returns big modulo other. See Numeric.divmod for more
4526 # information.
4527 def modulo(other); 0; end
4528 ##
4529 # Performs integer division: returns integer value.
4530 def div(other); 0; end
4531 ##
4532 # See <code>Numeric#divmod</code>.
4533 def divmod(numeric); []; end
4534 ##
4535 # Returns the remainder after dividing <i>big</i> by <i>numeric</i>.
4536 # 
4537 #    -1234567890987654321.remainder(13731)      #=> -6966
4538 #    -1234567890987654321.remainder(13731.24)   #=> -9906.22531493148
4539 def remainder(numeric); 0; end
4540 ##
4541 # Returns the floating point result of dividing <i>big</i> by
4542 # <i>numeric</i>.
4543 # 
4544 #    -1234567890987654321.fdiv(13731)      #=> -89910996357705.5
4545 #    -1234567890987654321.fdiv(13731.24)   #=> -89909424858035.7
4546 def fdiv(numeric); 0.0; end
4547 ##
4548 # Raises _big_ to the _exponent_ power (which may be an integer, float,
4549 # or anything that will coerce to a number). The result may be
4550 # a Fixnum, Bignum, or Float
4551 # 
4552 #   123456789 ** 2      #=> 15241578750190521
4553 #   123456789 ** 1.2    #=> 5126464716.09932
4554 #   123456789 ** -2     #=> 6.5610001194102e-17
4555 def **; 0; end
4556 ##
4557 # Performs bitwise +and+ between _big_ and _numeric_.
4558 def &; 0; end
4559 ##
4560 # Performs bitwise +or+ between _big_ and _numeric_.
4561 def |; 0; end
4562 ##
4563 # Performs bitwise +exclusive or+ between _big_ and _numeric_.
4564 def ^; 0; end
4565 ##
4566 # Inverts the bits in big. As Bignums are conceptually infinite
4567 # length, the result acts as if it had an infinite number of one
4568 # bits to the left. In hex representations, this is displayed
4569 # as two periods to the left of the digits.
4570 # 
4571 #   sprintf("%X", ~0x1122334455)    #=> "..FEEDDCCBBAA"
4572 def ~; 0; end
4573 ##
4574 # Shifts big left _numeric_ positions (right if _numeric_ is negative).
4575 def <<; 0; end
4576 ##
4577 # Shifts big right _numeric_ positions (left if _numeric_ is negative).
4578 def >>; 0; end
4579 ##
4580 # Bit Reference---Returns the <em>n</em>th bit in the (assumed) binary
4581 # representation of <i>big</i>, where <i>big</i>[0] is the least
4582 # significant bit.
4583 # 
4584 #    a = 9**15
4585 #    50.downto(0) do |n|
4586 #      print a[n]
4587 #    end
4588 # 
4589 # <em>produces:</em>
4590 # 
4591 #    000101110110100000111000011110010100111100010111001
4592 def []; 0; end
4593 ##
4594 # Comparison---Returns -1, 0, or +1 depending on whether +big+ is
4595 # less than, equal to, or greater than +numeric+. This is the
4596 # basis for the tests in Comparable.
4597 # 
4598 # +nil+ is returned if the two values are incomparable.
4599 def <=>; 1 || nil; end
4600 ##
4601 # Returns <code>true</code> only if <i>obj</i> has the same value
4602 # as <i>big</i>. Contrast this with <code>Bignum#eql?</code>, which
4603 # requires <i>obj</i> to be a <code>Bignum</code>.
4604 # 
4605 #    68719476736 == 68719476736.0   #=> true
4606 def ==; true || false; end
4607 ##
4608 # Returns <code>true</code> if the value of <code>big</code> is
4609 # greater than that of <code>real</code>.
4610 def >; true || false; end
4611 ##
4612 # Returns <code>true</code> if the value of <code>big</code> is
4613 # greater than or equal to that of <code>real</code>.
4614 def >=; true || false; end
4615 ##
4616 # Returns <code>true</code> if the value of <code>big</code> is
4617 # less than that of <code>real</code>.
4618 def <; true || false; end
4619 ##
4620 # Returns <code>true</code> if the value of <code>big</code> is
4621 # less than or equal to that of <code>real</code>.
4622 def <=; true || false; end
4623 ##
4624 # Returns <code>true</code> only if <i>obj</i> has the same value
4625 # as <i>big</i>. Contrast this with <code>Bignum#eql?</code>, which
4626 # requires <i>obj</i> to be a <code>Bignum</code>.
4627 # 
4628 #    68719476736 == 68719476736.0   #=> true
4629 def ===; true || false; end
4630 ##
4631 # Returns <code>true</code> only if <i>obj</i> is a
4632 # <code>Bignum</code> with the same value as <i>big</i>. Contrast this
4633 # with <code>Bignum#==</code>, which performs type conversions.
4634 # 
4635 #    68719476736.eql?(68719476736.0)   #=> false
4636 def eql?(obj); true || false; end
4637 ##
4638 # Compute a hash based on the value of _big_.
4639 def hash; 0; end
4640 ##
4641 # Converts <i>big</i> to a <code>Float</code>. If <i>big</i> doesn't
4642 # fit in a <code>Float</code>, the result is infinity.
4643 def to_f; 0.0; end
4644 ##
4645 # Returns the absolute value of <i>big</i>.
4646 # 
4647 #    -1234567890987654321.abs   #=> 1234567890987654321
4648 def abs; Bignum.new; end
4649 ##
4650 # Returns the number of bytes in the machine representation of
4651 # <i>big</i>.
4652 # 
4653 #    (256**10 - 1).size   #=> 12
4654 #    (256**20 - 1).size   #=> 20
4655 #    (256**40 - 1).size   #=> 40
4656 def size; 0; end
4657 ##
4658 # Returns <code>true</code> if <i>big</i> is an odd number.
4659 def odd?; true || false; end
4660 ##
4661 # Returns <code>true</code> if <i>big</i> is an even number.
4662 def even?; true || false; end
4663 end
4664 
4665 ##
4666 # Time is an abstraction of dates and times. Time is stored internally as
4667 # the number of seconds with fraction since the _Epoch_, January 1, 1970
4668 # 00:00 UTC. Also see the library module Date. The Time class treats GMT
4669 # (Greenwich Mean Time) and UTC (Coordinated Universal Time) as equivalent.
4670 # GMT is the older way of referring to these baseline times but persists in
4671 # the names of calls on POSIX systems.
4672 # 
4673 # All times may have fraction. Be aware of this fact when comparing times
4674 # with each other -- times that are apparently equal when displayed may be
4675 # different when compared.
4676 # 
4677 # Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer,
4678 # Bignum or Rational.
4679 # The integer is a number of nanoseconds since the _Epoch_ which can
4680 # represent 1823-11-12 to 2116-02-20.
4681 # When Bignum or Rational is used (before 1823, after 2116, under
4682 # nanosecond), Time works slower as when integer is used.
4683 # 
4684 # = Examples
4685 # 
4686 # All of these examples were done using the EST timezone which is GMT-5.
4687 # 
4688 # == Creating a new Time instance
4689 # 
4690 # You can create a new instance of Time with Time::new. This will use the
4691 # current system time. Time::now is an alias for this. You can also
4692 # pass parts of the time to Time::new such as year, month, minute, etc. When
4693 # you want to construct a time this way you must pass at least a year. If you
4694 # pass the year with nothing else time will default to January 1 of that year
4695 # at 00:00:00 with the current system timezone. Here are some examples:
4696 # 
4697 #   Time.new(2002)         #=> 2002-01-01 00:00:00 -0500
4698 #   Time.new(2002, 10)     #=> 2002-10-01 00:00:00 -0500
4699 #   Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500
4700 #   Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 -0200
4701 # 
4702 # You can also use #gm, #local and
4703 # #utc to infer GMT, local and UTC timezones instead of using
4704 # the current system setting.
4705 # 
4706 # You can also create a new time using Time::at which takes the number of
4707 # seconds (or fraction of seconds) since the {Unix
4708 # Epoch}[http://en.wikipedia.org/wiki/Unix_time].
4709 # 
4710 #   Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
4711 # 
4712 # == Working with an instance of Time
4713 # 
4714 # Once you have an instance of Time there is a multitude of things you can
4715 # do with it. Below are some examples. For all of the following examples, we
4716 # will work on the assumption that you have done the following:
4717 # 
4718 #   t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00")
4719 # 
4720 # Was that a monday?
4721 # 
4722 #   t.monday? #=> false
4723 # 
4724 # What year was that again?
4725 # 
4726 #   t.year #=> 1993
4727 # 
4728 # Was is daylight savings at the time?
4729 # 
4730 #   t.dst? #=> false
4731 # 
4732 # What's the day a year later?
4733 # 
4734 #   t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900
4735 # 
4736 # How many seconds was that since the Unix Epoch?
4737 # 
4738 #   t.to_i #=> 730522800
4739 # 
4740 # You can also do standard functions like compare two times.
4741 # 
4742 #   t1 = Time.new(2010)
4743 #   t2 = Time.new(2011)
4744 # 
4745 #   t1 == t2 #=> false
4746 #   t1 == t1 #=> true
4747 #   t1 <  t2 #=> true
4748 #   t1 >  t2 #=> false
4749 # 
4750 #   Time.new(2010,10,31).between?(t1, t2) #=> true
4751 class Time < Object
4752 include Comparable
4753 ##
4754 # Creates a new Time object with the value given by +time+,
4755 # the given number of +seconds_with_frac+, or
4756 # +seconds+ and +microseconds_with_frac+ since the Epoch.
4757 # +seconds_with_frac+ and +microseconds_with_frac+
4758 # can be an Integer, Float, Rational, or other Numeric.
4759 # non-portable feature allows the offset to be negative on some systems.
4760 # 
4761 # If a numeric argument is given, the result is in local time.
4762 # 
4763 #    Time.at(0)                           #=> 1969-12-31 18:00:00 -0600
4764 #    Time.at(Time.at(0))                  #=> 1969-12-31 18:00:00 -0600
4765 #    Time.at(946702800)                   #=> 1999-12-31 23:00:00 -0600
4766 #    Time.at(-284061600)                  #=> 1960-12-31 00:00:00 -0600
4767 #    Time.at(946684800.2).usec            #=> 200000
4768 #    Time.at(946684800, 123456.789).nsec  #=> 123456789
4769 def self.at(time); Time.new; end
4770 ##
4771 # Creates a Time object based on given values, interpreted as UTC (GMT). The
4772 # year must be specified. Other values default to the minimum value
4773 # for that field (and may be +nil+ or omitted). Months may
4774 # be specified by numbers from 1 to 12, or by the three-letter English
4775 # month names. Hours are specified on a 24-hour clock (0..23). Raises
4776 # an ArgumentError if any values are out of range. Will
4777 # also accept ten arguments in the order output by Time#to_a.
4778 # 
4779 # +sec_with_frac+ and +usec_with_frac+ can have a fractional part.
4780 # 
4781 #    Time.utc(2000,"jan",1,20,15,1)  #=> 2000-01-01 20:15:01 UTC
4782 #    Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
4783 def self.utc(year); Time.new; end
4784 ##
4785 # Creates a Time object based on given values, interpreted as UTC (GMT). The
4786 # year must be specified. Other values default to the minimum value
4787 # for that field (and may be +nil+ or omitted). Months may
4788 # be specified by numbers from 1 to 12, or by the three-letter English
4789 # month names. Hours are specified on a 24-hour clock (0..23). Raises
4790 # an ArgumentError if any values are out of range. Will
4791 # also accept ten arguments in the order output by Time#to_a.
4792 # 
4793 # +sec_with_frac+ and +usec_with_frac+ can have a fractional part.
4794 # 
4795 #    Time.utc(2000,"jan",1,20,15,1)  #=> 2000-01-01 20:15:01 UTC
4796 #    Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
4797 def self.gm(year); Time.new; end
4798 ##
4799 # Same as Time::gm, but interprets the values in the
4800 # local time zone.
4801 # 
4802 #    Time.local(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
4803 def self.local(year); Time.new; end
4804 ##
4805 # Same as Time::gm, but interprets the values in the
4806 # local time zone.
4807 # 
4808 #    Time.local(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
4809 def self.mktime(year); Time.new; end
4810 ##
4811 # Returns the value of _time_ as an integer number of seconds
4812 # since the Epoch.
4813 # 
4814 #    t = Time.now
4815 #    "%10.5f" % t.to_f   #=> "1270968656.89607"
4816 #    t.to_i              #=> 1270968656
4817 def to_i; 0; end
4818 ##
4819 # Returns the value of _time_ as an integer number of seconds
4820 # since the Epoch.
4821 # 
4822 #    t = Time.now
4823 #    "%10.5f" % t.to_f   #=> "1270968656.89607"
4824 #    t.to_i              #=> 1270968656
4825 def tv_sec; 0; end
4826 ##
4827 # Returns the value of _time_ as a floating point number of
4828 # seconds since the Epoch.
4829 # 
4830 #    t = Time.now
4831 #    "%10.5f" % t.to_f   #=> "1270968744.77658"
4832 #    t.to_i              #=> 1270968744
4833 # 
4834 # Note that IEEE 754 double is not accurate enough to represent
4835 # the number of nanoseconds since the Epoch.
4836 def to_f; 0.0; end
4837 ##
4838 # Returns the value of _time_ as a rational number of seconds
4839 # since the Epoch.
4840 # 
4841 #    t = Time.now
4842 #    p t.to_r            #=> (1270968792716287611/1000000000)
4843 # 
4844 # This methods is intended to be used to get an accurate value
4845 # representing the nanoseconds since the Epoch. You can use this method
4846 # to convert _time_ to another Epoch.
4847 def to_r; Rational.new; end
4848 ##
4849 # Comparison---Compares +time+ with +other_time+.
4850 # 
4851 # -1, 0, +1 or nil depending on whether +time+ is less  than, equal to, or
4852 # greater than +other_time+.
4853 # 
4854 # +nil+ is returned if the two values are incomparable.
4855 # 
4856 #    t = Time.now       #=> 2007-11-19 08:12:12 -0600
4857 #    t2 = t + 2592000   #=> 2007-12-19 08:12:12 -0600
4858 #    t <=> t2           #=> -1
4859 #    t2 <=> t           #=> 1
4860 # 
4861 #    t = Time.now       #=> 2007-11-19 08:13:38 -0600
4862 #    t2 = t + 0.1       #=> 2007-11-19 08:13:38 -0600
4863 #    t.nsec             #=> 98222999
4864 #    t2.nsec            #=> 198222999
4865 #    t <=> t2           #=> -1
4866 #    t2 <=> t           #=> 1
4867 #    t <=> t            #=> 0
4868 def <=>; 1 || nil; end
4869 ##
4870 # Returns +true+ if _time_ and +other_time+ are
4871 # both Time objects with the same seconds and fractional seconds.
4872 def eql?(other_time); end
4873 ##
4874 # Returns a hash code for this Time object.
4875 def hash; 0; end
4876 ##
4877 # Returns a Time object.
4878 # 
4879 # It is initialized to the current system time if no argument is given.
4880 # 
4881 # *Note:* The new object will use the resolution available on your
4882 # system clock, and may include fractional seconds.
4883 # 
4884 # If one or more arguments specified, the time is initialized to the specified
4885 # time.
4886 # 
4887 # +sec+ may have fraction if it is a rational.
4888 # 
4889 # +utc_offset+ is the offset from UTC.
4890 # It can be a string such as "+09:00" or a number of seconds such as 32400.
4891 # 
4892 #    a = Time.new      #=> 2007-11-19 07:50:02 -0600
4893 #    b = Time.new      #=> 2007-11-19 07:50:02 -0600
4894 #    a == b            #=> false
4895 #    "%.6f" % a.to_f   #=> "1195480202.282373"
4896 #    "%.6f" % b.to_f   #=> "1195480202.283415"
4897 # 
4898 #    Time.new(2008,6,21, 13,30,0, "+09:00") #=> 2008-06-21 13:30:00 +0900
4899 # 
4900 #    # A trip for RubyConf 2007
4901 #    t1 = Time.new(2007,11,1,15,25,0, "+09:00") # JST (Narita)
4902 #    t2 = Time.new(2007,11,1,12, 5,0, "-05:00") # CDT (Minneapolis)
4903 #    t3 = Time.new(2007,11,1,13,25,0, "-05:00") # CDT (Minneapolis)
4904 #    t4 = Time.new(2007,11,1,16,53,0, "-04:00") # EDT (Charlotte)
4905 #    t5 = Time.new(2007,11,5, 9,24,0, "-05:00") # EST (Charlotte)
4906 #    t6 = Time.new(2007,11,5,11,21,0, "-05:00") # EST (Detroit)
4907 #    t7 = Time.new(2007,11,5,13,45,0, "-05:00") # EST (Detroit)
4908 #    t8 = Time.new(2007,11,6,17,10,0, "+09:00") # JST (Narita)
4909 #    p((t2-t1)/3600.0)                          #=> 10.666666666666666
4910 #    p((t4-t3)/3600.0)                          #=> 2.466666666666667
4911 #    p((t6-t5)/3600.0)                          #=> 1.95
4912 #    p((t8-t7)/3600.0)                          #=> 13.416666666666666
4913 def self.new; end
4914 ##
4915 # Converts _time_ to local time (using the local time zone in
4916 # effect for this process) modifying the receiver.
4917 # 
4918 # If +utc_offset+ is given, it is used instead of the local time.
4919 # 
4920 #    t = Time.utc(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC
4921 #    t.utc?                                  #=> true
4922 # 
4923 #    t.localtime                             #=> 2000-01-01 14:15:01 -0600
4924 #    t.utc?                                  #=> false
4925 # 
4926 #    t.localtime("+09:00")                   #=> 2000-01-02 05:15:01 +0900
4927 #    t.utc?                                  #=> false
4928 def localtime; Time.new; end
4929 ##
4930 # Converts _time_ to UTC (GMT), modifying the receiver.
4931 # 
4932 #    t = Time.now   #=> 2007-11-19 08:18:31 -0600
4933 #    t.gmt?         #=> false
4934 #    t.gmtime       #=> 2007-11-19 14:18:31 UTC
4935 #    t.gmt?         #=> true
4936 # 
4937 #    t = Time.now   #=> 2007-11-19 08:18:51 -0600
4938 #    t.utc?         #=> false
4939 #    t.utc          #=> 2007-11-19 14:18:51 UTC
4940 #    t.utc?         #=> true
4941 def gmtime; Time.new; end
4942 ##
4943 # Returns a new Time object representing _time_ in
4944 # local time (using the local time zone in effect for this process).
4945 # 
4946 # If +utc_offset+ is given, it is used instead of the local time.
4947 # 
4948 #    t = Time.utc(2000,1,1,20,15,1)  #=> 2000-01-01 20:15:01 UTC
4949 #    t.utc?                          #=> true
4950 # 
4951 #    l = t.getlocal                  #=> 2000-01-01 14:15:01 -0600
4952 #    l.utc?                          #=> false
4953 #    t == l                          #=> true
4954 # 
4955 #    j = t.getlocal("+09:00")        #=> 2000-01-02 05:15:01 +0900
4956 #    j.utc?                          #=> false
4957 #    t == j                          #=> true
4958 def getlocal; Time.new; end
4959 ##
4960 # Returns a new Time object representing _time_ in UTC.
4961 # 
4962 #    t = Time.local(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
4963 #    t.gmt?                             #=> false
4964 #    y = t.getgm                        #=> 2000-01-02 02:15:01 UTC
4965 #    y.gmt?                             #=> true
4966 #    t == y                             #=> true
4967 def getgm; Time.new; end
4968 ##
4969 # Returns a new Time object representing _time_ in UTC.
4970 # 
4971 #    t = Time.local(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 -0600
4972 #    t.gmt?                             #=> false
4973 #    y = t.getgm                        #=> 2000-01-02 02:15:01 UTC
4974 #    y.gmt?                             #=> true
4975 #    t == y                             #=> true
4976 def getutc; Time.new; end
4977 ##
4978 # Returns a canonical string representation of _time_.
4979 # 
4980 #    Time.now.asctime   #=> "Wed Apr  9 08:56:03 2003"
4981 def asctime; ''; end
4982 ##
4983 # Returns a canonical string representation of _time_.
4984 # 
4985 #    Time.now.asctime   #=> "Wed Apr  9 08:56:03 2003"
4986 def ctime; ''; end
4987 ##
4988 # Returns a string representing _time_. Equivalent to calling
4989 # #strftime with the appropriate format string.
4990 # 
4991 #    t = Time.now
4992 #    t.to_s                              => "2012-11-10 18:16:12 +0100"
4993 #    t.strftime "%Y-%m-%d %H:%M:%S %z"   => "2012-11-10 18:16:12 +0100"
4994 # 
4995 #    t.utc.to_s                          => "2012-11-10 17:16:12 UTC"
4996 #    t.strftime "%Y-%m-%d %H:%M:%S UTC"  => "2012-11-10 17:16:12 UTC"
4997 def inspect; ''; end
4998 ##
4999 # Returns a string representing _time_. Equivalent to calling
5000 # #strftime with the appropriate format string.
5001 # 
5002 #    t = Time.now
5003 #    t.to_s                              => "2012-11-10 18:16:12 +0100"
5004 #    t.strftime "%Y-%m-%d %H:%M:%S %z"   => "2012-11-10 18:16:12 +0100"
5005 # 
5006 #    t.utc.to_s                          => "2012-11-10 17:16:12 UTC"
5007 #    t.strftime "%Y-%m-%d %H:%M:%S UTC"  => "2012-11-10 17:16:12 UTC"
5008 def to_s; ''; end
5009 ##
5010 # Returns a ten-element _array_ of values for _time_:
5011 # 
5012 #    [sec, min, hour, day, month, year, wday, yday, isdst, zone]
5013 # 
5014 # See the individual methods for an explanation of the
5015 # valid ranges of each value. The ten elements can be passed directly
5016 # to Time::utc or Time::local to create a
5017 # new Time object.
5018 # 
5019 #    t = Time.now     #=> 2007-11-19 08:36:01 -0600
5020 #    now = t.to_a     #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
5021 def to_a; []; end
5022 ##
5023 # Addition --- Adds some number of seconds (possibly fractional) to
5024 # _time_ and returns that value as a new Time object.
5025 # 
5026 #    t = Time.now         #=> 2007-11-19 08:22:21 -0600
5027 #    t + (60 * 60 * 24)   #=> 2007-11-20 08:22:21 -0600
5028 def +; Time.new; end
5029 ##
5030 # Difference --- Returns a new Time object that represents the difference
5031 # between _time_ and +other_time+, or subtracts the given number
5032 # of seconds in +numeric+ from _time_.
5033 # 
5034 #    t = Time.now       #=> 2007-11-19 08:23:10 -0600
5035 #    t2 = t + 2592000   #=> 2007-12-19 08:23:10 -0600
5036 #    t2 - t             #=> 2592000.0
5037 #    t2 - 2592000       #=> 2007-11-19 08:23:10 -0600
5038 def -; Time.new; end
5039 ##
5040 # Returns a new Time object, one second later than _time_.
5041 # Time#succ is obsolete since 1.9.2 for time is not a discrete value.
5042 # 
5043 #     t = Time.now       #=> 2007-11-19 08:23:57 -0600
5044 #     t.succ             #=> 2007-11-19 08:23:58 -0600
5045 # 
5046 # Use instead <code>time + 1</code>
5047 # 
5048 #     t + 1              #=> 2007-11-19 08:23:58 -0600
5049 def succ; Time.new; end
5050 ##
5051 # Rounds sub seconds to a given precision in decimal digits (0 digits by default).
5052 # It returns a new Time object.
5053 # +ndigits+ should be zero or positive integer.
5054 # 
5055 #     require 'time'
5056 # 
5057 #     t = Time.utc(2010,3,30, 5,43,"25.123456789".to_r)
5058 #     p t.iso8601(10)           #=> "2010-03-30T05:43:25.1234567890Z"
5059 #     p t.round.iso8601(10)     #=> "2010-03-30T05:43:25.0000000000Z"
5060 #     p t.round(0).iso8601(10)  #=> "2010-03-30T05:43:25.0000000000Z"
5061 #     p t.round(1).iso8601(10)  #=> "2010-03-30T05:43:25.1000000000Z"
5062 #     p t.round(2).iso8601(10)  #=> "2010-03-30T05:43:25.1200000000Z"
5063 #     p t.round(3).iso8601(10)  #=> "2010-03-30T05:43:25.1230000000Z"
5064 #     p t.round(4).iso8601(10)  #=> "2010-03-30T05:43:25.1235000000Z"
5065 #     p t.round(5).iso8601(10)  #=> "2010-03-30T05:43:25.1234600000Z"
5066 #     p t.round(6).iso8601(10)  #=> "2010-03-30T05:43:25.1234570000Z"
5067 #     p t.round(7).iso8601(10)  #=> "2010-03-30T05:43:25.1234568000Z"
5068 #     p t.round(8).iso8601(10)  #=> "2010-03-30T05:43:25.1234567900Z"
5069 #     p t.round(9).iso8601(10)  #=> "2010-03-30T05:43:25.1234567890Z"
5070 #     p t.round(10).iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z"
5071 # 
5072 #     t = Time.utc(1999,12,31, 23,59,59)
5073 #     p((t + 0.4).round.iso8601(3))    #=> "1999-12-31T23:59:59.000Z"
5074 #     p((t + 0.49).round.iso8601(3))   #=> "1999-12-31T23:59:59.000Z"
5075 #     p((t + 0.5).round.iso8601(3))    #=> "2000-01-01T00:00:00.000Z"
5076 #     p((t + 1.4).round.iso8601(3))    #=> "2000-01-01T00:00:00.000Z"
5077 #     p((t + 1.49).round.iso8601(3))   #=> "2000-01-01T00:00:00.000Z"
5078 #     p((t + 1.5).round.iso8601(3))    #=> "2000-01-01T00:00:01.000Z"
5079 # 
5080 #     t = Time.utc(1999,12,31, 23,59,59)
5081 #     p (t + 0.123456789).round(4).iso8601(6)  #=> "1999-12-31T23:59:59.123500Z"
5082 def round(ndigits=0); Time.new; end
5083 ##
5084 # Returns the second of the minute (0..60) for _time_.
5085 # 
5086 # *Note:* Seconds range from zero to 60 to allow the system to inject
5087 # leap seconds. See http://en.wikipedia.org/wiki/Leap_second for further
5088 # details.
5089 # 
5090 #    t = Time.now   #=> 2007-11-19 08:25:02 -0600
5091 #    t.sec          #=> 2
5092 def sec; 0; end
5093 ##
5094 # Returns the minute of the hour (0..59) for _time_.
5095 # 
5096 #    t = Time.now   #=> 2007-11-19 08:25:51 -0600
5097 #    t.min          #=> 25
5098 def min; 0; end
5099 ##
5100 # Returns the hour of the day (0..23) for _time_.
5101 # 
5102 #    t = Time.now   #=> 2007-11-19 08:26:20 -0600
5103 #    t.hour         #=> 8
5104 def hour; 0; end
5105 ##
5106 # Returns the day of the month (1..n) for _time_.
5107 # 
5108 #    t = Time.now   #=> 2007-11-19 08:27:03 -0600
5109 #    t.day          #=> 19
5110 #    t.mday         #=> 19
5111 def day; 0; end
5112 ##
5113 # Returns the day of the month (1..n) for _time_.
5114 # 
5115 #    t = Time.now   #=> 2007-11-19 08:27:03 -0600
5116 #    t.day          #=> 19
5117 #    t.mday         #=> 19
5118 def mday; 0; end
5119 ##
5120 # Returns the month of the year (1..12) for _time_.
5121 # 
5122 #    t = Time.now   #=> 2007-11-19 08:27:30 -0600
5123 #    t.mon          #=> 11
5124 #    t.month        #=> 11
5125 def mon; 0; end
5126 ##
5127 # Returns the month of the year (1..12) for _time_.
5128 # 
5129 #    t = Time.now   #=> 2007-11-19 08:27:30 -0600
5130 #    t.mon          #=> 11
5131 #    t.month        #=> 11
5132 def month; 0; end
5133 ##
5134 # Returns the year for _time_ (including the century).
5135 # 
5136 #    t = Time.now   #=> 2007-11-19 08:27:51 -0600
5137 #    t.year         #=> 2007
5138 def year; 0; end
5139 ##
5140 # Returns an integer representing the day of the week, 0..6, with
5141 # Sunday == 0.
5142 # 
5143 #    t = Time.now   #=> 2007-11-20 02:35:35 -0600
5144 #    t.wday         #=> 2
5145 #    t.sunday?      #=> false
5146 #    t.monday?      #=> false
5147 #    t.tuesday?     #=> true
5148 #    t.wednesday?   #=> false
5149 #    t.thursday?    #=> false
5150 #    t.friday?      #=> false
5151 #    t.saturday?    #=> false
5152 def wday; 0; end
5153 ##
5154 # Returns an integer representing the day of the year, 1..366.
5155 # 
5156 #    t = Time.now   #=> 2007-11-19 08:32:31 -0600
5157 #    t.yday         #=> 323
5158 def yday; 0; end
5159 ##
5160 # Returns +true+ if _time_ occurs during Daylight
5161 # Saving Time in its time zone.
5162 # 
5163 #  # CST6CDT:
5164 #    Time.local(2000, 1, 1).zone    #=> "CST"
5165 #    Time.local(2000, 1, 1).isdst   #=> false
5166 #    Time.local(2000, 1, 1).dst?    #=> false
5167 #    Time.local(2000, 7, 1).zone    #=> "CDT"
5168 #    Time.local(2000, 7, 1).isdst   #=> true
5169 #    Time.local(2000, 7, 1).dst?    #=> true
5170 # 
5171 #  # Asia/Tokyo:
5172 #    Time.local(2000, 1, 1).zone    #=> "JST"
5173 #    Time.local(2000, 1, 1).isdst   #=> false
5174 #    Time.local(2000, 1, 1).dst?    #=> false
5175 #    Time.local(2000, 7, 1).zone    #=> "JST"
5176 #    Time.local(2000, 7, 1).isdst   #=> false
5177 #    Time.local(2000, 7, 1).dst?    #=> false
5178 def isdst; true || false; end
5179 ##
5180 # Returns +true+ if _time_ occurs during Daylight
5181 # Saving Time in its time zone.
5182 # 
5183 #  # CST6CDT:
5184 #    Time.local(2000, 1, 1).zone    #=> "CST"
5185 #    Time.local(2000, 1, 1).isdst   #=> false
5186 #    Time.local(2000, 1, 1).dst?    #=> false
5187 #    Time.local(2000, 7, 1).zone    #=> "CDT"
5188 #    Time.local(2000, 7, 1).isdst   #=> true
5189 #    Time.local(2000, 7, 1).dst?    #=> true
5190 # 
5191 #  # Asia/Tokyo:
5192 #    Time.local(2000, 1, 1).zone    #=> "JST"
5193 #    Time.local(2000, 1, 1).isdst   #=> false
5194 #    Time.local(2000, 1, 1).dst?    #=> false
5195 #    Time.local(2000, 7, 1).zone    #=> "JST"
5196 #    Time.local(2000, 7, 1).isdst   #=> false
5197 #    Time.local(2000, 7, 1).dst?    #=> false
5198 def dst?; true || false; end
5199 ##
5200 # Returns the name of the time zone used for _time_. As of Ruby
5201 # 1.8, returns ``UTC'' rather than ``GMT'' for UTC times.
5202 # 
5203 #    t = Time.gm(2000, "jan", 1, 20, 15, 1)
5204 #    t.zone   #=> "UTC"
5205 #    t = Time.local(2000, "jan", 1, 20, 15, 1)
5206 #    t.zone   #=> "CST"
5207 def zone; ''; end
5208 ##
5209 # Returns the offset in seconds between the timezone of _time_
5210 # and UTC.
5211 # 
5212 #    t = Time.gm(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
5213 #    t.gmt_offset                    #=> 0
5214 #    l = t.getlocal                  #=> 2000-01-01 14:15:01 -0600
5215 #    l.gmt_offset                    #=> -21600
5216 def gmt_offset; 0; end
5217 ##
5218 # Returns the offset in seconds between the timezone of _time_
5219 # and UTC.
5220 # 
5221 #    t = Time.gm(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
5222 #    t.gmt_offset                    #=> 0
5223 #    l = t.getlocal                  #=> 2000-01-01 14:15:01 -0600
5224 #    l.gmt_offset                    #=> -21600
5225 def gmtoff; 0; end
5226 ##
5227 # Returns the offset in seconds between the timezone of _time_
5228 # and UTC.
5229 # 
5230 #    t = Time.gm(2000,1,1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
5231 #    t.gmt_offset                    #=> 0
5232 #    l = t.getlocal                  #=> 2000-01-01 14:15:01 -0600
5233 #    l.gmt_offset                    #=> -21600
5234 def utc_offset; 0; end
5235 ##
5236 # Returns +true+ if _time_ represents a time in UTC (GMT).
5237 # 
5238 #    t = Time.now                        #=> 2007-11-19 08:15:23 -0600
5239 #    t.utc?                              #=> false
5240 #    t = Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
5241 #    t.utc?                              #=> true
5242 # 
5243 #    t = Time.now                        #=> 2007-11-19 08:16:03 -0600
5244 #    t.gmt?                              #=> false
5245 #    t = Time.gm(2000,1,1,20,15,1)       #=> 2000-01-01 20:15:01 UTC
5246 #    t.gmt?                              #=> true
5247 def utc?; true || false; end
5248 ##
5249 # Returns +true+ if _time_ represents a time in UTC (GMT).
5250 # 
5251 #    t = Time.now                        #=> 2007-11-19 08:15:23 -0600
5252 #    t.utc?                              #=> false
5253 #    t = Time.gm(2000,"jan",1,20,15,1)   #=> 2000-01-01 20:15:01 UTC
5254 #    t.utc?                              #=> true
5255 # 
5256 #    t = Time.now                        #=> 2007-11-19 08:16:03 -0600
5257 #    t.gmt?                              #=> false
5258 #    t = Time.gm(2000,1,1,20,15,1)       #=> 2000-01-01 20:15:01 UTC
5259 #    t.gmt?                              #=> true
5260 def gmt?; true || false; end
5261 ##
5262 # Returns +true+ if _time_ represents Sunday.
5263 # 
5264 #    t = Time.local(1990, 4, 1)       #=> 1990-04-01 00:00:00 -0600
5265 #    t.sunday?                        #=> true
5266 def sunday?; true || false; end
5267 ##
5268 # Returns +true+ if _time_ represents Monday.
5269 # 
5270 #    t = Time.local(2003, 8, 4)       #=> 2003-08-04 00:00:00 -0500
5271 #    p t.monday?                      #=> true
5272 def monday?; true || false; end
5273 ##
5274 # Returns +true+ if _time_ represents Tuesday.
5275 # 
5276 #    t = Time.local(1991, 2, 19)      #=> 1991-02-19 00:00:00 -0600
5277 #    p t.tuesday?                     #=> true
5278 def tuesday?; true || false; end
5279 ##
5280 # Returns +true+ if _time_ represents Wednesday.
5281 # 
5282 #    t = Time.local(1993, 2, 24)      #=> 1993-02-24 00:00:00 -0600
5283 #    p t.wednesday?                   #=> true
5284 def wednesday?; true || false; end
5285 ##
5286 # Returns +true+ if _time_ represents Thursday.
5287 # 
5288 #    t = Time.local(1995, 12, 21)     #=> 1995-12-21 00:00:00 -0600
5289 #    p t.thursday?                    #=> true
5290 def thursday?; true || false; end
5291 ##
5292 # Returns +true+ if _time_ represents Friday.
5293 # 
5294 #    t = Time.local(1987, 12, 18)     #=> 1987-12-18 00:00:00 -0600
5295 #    t.friday?                        #=> true
5296 def friday?; true || false; end
5297 ##
5298 # Returns +true+ if _time_ represents Saturday.
5299 # 
5300 #    t = Time.local(2006, 6, 10)      #=> 2006-06-10 00:00:00 -0500
5301 #    t.saturday?                      #=> true
5302 def saturday?; true || false; end
5303 ##
5304 # Returns the number of microseconds for _time_.
5305 # 
5306 #    t = Time.now        #=> 2007-11-19 08:03:26 -0600
5307 #    "%10.6f" % t.to_f   #=> "1195481006.775195"
5308 #    t.usec              #=> 775195
5309 def usec; 0; end
5310 ##
5311 # Returns the number of microseconds for _time_.
5312 # 
5313 #    t = Time.now        #=> 2007-11-19 08:03:26 -0600
5314 #    "%10.6f" % t.to_f   #=> "1195481006.775195"
5315 #    t.usec              #=> 775195
5316 def tv_usec; 0; end
5317 ##
5318 # Returns the number of nanoseconds for _time_.
5319 # 
5320 #    t = Time.now        #=> 2007-11-17 15:18:03 +0900
5321 #    "%10.9f" % t.to_f   #=> "1195280283.536151409"
5322 #    t.nsec              #=> 536151406
5323 # 
5324 # The lowest digits of #to_f and #nsec are different because
5325 # IEEE 754 double is not accurate enough to represent
5326 # the exact number of nanoseconds since the Epoch.
5327 # 
5328 # The more accurate value is returned by #nsec.
5329 def nsec; 0; end
5330 ##
5331 # Returns the number of nanoseconds for _time_.
5332 # 
5333 #    t = Time.now        #=> 2007-11-17 15:18:03 +0900
5334 #    "%10.9f" % t.to_f   #=> "1195280283.536151409"
5335 #    t.nsec              #=> 536151406
5336 # 
5337 # The lowest digits of #to_f and #nsec are different because
5338 # IEEE 754 double is not accurate enough to represent
5339 # the exact number of nanoseconds since the Epoch.
5340 # 
5341 # The more accurate value is returned by #nsec.
5342 def tv_nsec; 0; end
5343 ##
5344 # Returns the fraction for _time_.
5345 # 
5346 # The return value can be a rational number.
5347 # 
5348 #    t = Time.now        #=> 2009-03-26 22:33:12 +0900
5349 #    "%10.9f" % t.to_f   #=> "1238074392.940563917"
5350 #    t.subsec            #=> (94056401/100000000)
5351 # 
5352 # The lowest digits of #to_f and #subsec are different because
5353 # IEEE 754 double is not accurate enough to represent
5354 # the rational number.
5355 # 
5356 # The more accurate value is returned by #subsec.
5357 def subsec; 0; end
5358 ##
5359 # Formats _time_ according to the directives in the given format string.
5360 # 
5361 # The directives begin with a percent (%) character.
5362 # Any text not listed as a directive will be passed through to the
5363 # output string.
5364 # 
5365 # The directive consists of a percent (%) character,
5366 # zero or more flags, optional minimum field width,
5367 # optional modifier and a conversion specifier
5368 # as follows:
5369 # 
5370 #   %<flags><width><modifier><conversion>
5371 # 
5372 # Flags:
5373 #   -  don't pad a numerical output
5374 #   _  use spaces for padding
5375 #   0  use zeros for padding
5376 #   ^  upcase the result string
5377 #   #  change case
5378 #   :  use colons for %z
5379 # 
5380 # The minimum field width specifies the minimum width.
5381 # 
5382 # The modifiers are "E" and "O".
5383 # They are ignored.
5384 # 
5385 # Format directives:
5386 # 
5387 #   Date (Year, Month, Day):
5388 #     %Y - Year with century (can be negative, 4 digits at least)
5389 #             -0001, 0000, 1995, 2009, 14292, etc.
5390 #     %C - year / 100 (rounded down such as 20 in 2009)
5391 #     %y - year % 100 (00..99)
5392 # 
5393 #     %m - Month of the year, zero-padded (01..12)
5394 #             %_m  blank-padded ( 1..12)
5395 #             %-m  no-padded (1..12)
5396 #     %B - The full month name (``January'')
5397 #             %^B  uppercased (``JANUARY'')
5398 #     %b - The abbreviated month name (``Jan'')
5399 #             %^b  uppercased (``JAN'')
5400 #     %h - Equivalent to %b
5401 # 
5402 #     %d - Day of the month, zero-padded (01..31)
5403 #             %-d  no-padded (1..31)
5404 #     %e - Day of the month, blank-padded ( 1..31)
5405 # 
5406 #     %j - Day of the year (001..366)
5407 # 
5408 #   Time (Hour, Minute, Second, Subsecond):
5409 #     %H - Hour of the day, 24-hour clock, zero-padded (00..23)
5410 #     %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
5411 #     %I - Hour of the day, 12-hour clock, zero-padded (01..12)
5412 #     %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
5413 #     %P - Meridian indicator, lowercase (``am'' or ``pm'')
5414 #     %p - Meridian indicator, uppercase (``AM'' or ``PM'')
5415 # 
5416 #     %M - Minute of the hour (00..59)
5417 # 
5418 #     %S - Second of the minute (00..60)
5419 # 
5420 #     %L - Millisecond of the second (000..999)
5421 #     %N - Fractional seconds digits, default is 9 digits (nanosecond)
5422 #             %3N  milli second (3 digits)
5423 #             %6N  micro second (6 digits)
5424 #             %9N  nano second (9 digits)
5425 #             %12N pico second (12 digits)
5426 #             %15N femto second (15 digits)
5427 #             %18N atto second (18 digits)
5428 #             %21N zepto second (21 digits)
5429 #             %24N yocto second (24 digits)
5430 # 
5431 #   Time zone:
5432 #     %z - Time zone as hour and minute offset from UTC (e.g. +0900)
5433 #             %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
5434 #             %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
5435 #     %Z - Abbreviated time zone name or similar information.
5436 # 
5437 #   Weekday:
5438 #     %A - The full weekday name (``Sunday'')
5439 #             %^A  uppercased (``SUNDAY'')
5440 #     %a - The abbreviated name (``Sun'')
5441 #             %^a  uppercased (``SUN'')
5442 #     %u - Day of the week (Monday is 1, 1..7)
5443 #     %w - Day of the week (Sunday is 0, 0..6)
5444 # 
5445 #   ISO 8601 week-based year and week number:
5446 #   The first week of YYYY starts with a Monday and includes YYYY-01-04.
5447 #   The days in the year before the first week are in the last week of
5448 #   the previous year.
5449 #     %G - The week-based year
5450 #     %g - The last 2 digits of the week-based year (00..99)
5451 #     %V - Week number of the week-based year (01..53)
5452 # 
5453 #   Week number:
5454 #   The first week of YYYY that starts with a Sunday or Monday (according to %U
5455 #   or %W). The days in the year before the first week are in week 0.
5456 #     %U - Week number of the year. The week starts with Sunday. (00..53)
5457 #     %W - Week number of the year. The week starts with Monday. (00..53)
5458 # 
5459 #   Seconds since the Epoch:
5460 #     %s - Number of seconds since 1970-01-01 00:00:00 UTC.
5461 # 
5462 #   Literal string:
5463 #     %n - Newline character (\n)
5464 #     %t - Tab character (\t)
5465 #     %% - Literal ``%'' character
5466 # 
5467 #   Combination:
5468 #     %c - date and time (%a %b %e %T %Y)
5469 #     %D - Date (%m/%d/%y)
5470 #     %F - The ISO 8601 date format (%Y-%m-%d)
5471 #     %v - VMS date (%e-%^b-%4Y)
5472 #     %x - Same as %D
5473 #     %X - Same as %T
5474 #     %r - 12-hour time (%I:%M:%S %p)
5475 #     %R - 24-hour time (%H:%M)
5476 #     %T - 24-hour time (%H:%M:%S)
5477 # 
5478 # This method is similar to strftime() function defined in ISO C and POSIX.
5479 # 
5480 # While all directives are locale independant since Ruby 1.9 %Z is platform
5481 # dependant.
5482 # So, the result may differ even if the same format string is used in other
5483 # systems such as C.
5484 # 
5485 # %z is recommended over %Z.
5486 # %Z doesn't identify the timezone.
5487 # For example, "CST" is used at America/Chicago (-06:00),
5488 # America/Havana (-05:00), Asia/Harbin (+08:00), Australia/Darwin (+09:30)
5489 # and Australia/Adelaide (+10:30).
5490 # Also, %Z is highly dependent on the operating system.
5491 # For example, it may generate a non ASCII string on Japanese Windows.
5492 # i.e. the result can be different to "JST".
5493 # So the numeric time zone offset, %z, is recommended.
5494 # 
5495 # Examples:
5496 # 
5497 #   t = Time.new(2007,11,19,8,37,48,"-06:00") #=> 2007-11-19 08:37:48 -0600
5498 #   t.strftime("Printed on %m/%d/%Y")   #=> "Printed on 11/19/2007"
5499 #   t.strftime("at %I:%M%p")            #=> "at 08:37AM"
5500 # 
5501 # Various ISO 8601 formats:
5502 #   %Y%m%d           => 20071119                  Calendar date (basic)
5503 #   %F               => 2007-11-19                Calendar date (extended)
5504 #   %Y-%m            => 2007-11                   Calendar date, reduced accuracy, specific month
5505 #   %Y               => 2007                      Calendar date, reduced accuracy, specific year
5506 #   %C               => 20                        Calendar date, reduced accuracy, specific century
5507 #   %Y%j             => 2007323                   Ordinal date (basic)
5508 #   %Y-%j            => 2007-323                  Ordinal date (extended)
5509 #   %GW%V%u          => 2007W471                  Week date (basic)
5510 #   %G-W%V-%u        => 2007-W47-1                Week date (extended)
5511 #   %GW%V            => 2007W47                   Week date, reduced accuracy, specific week (basic)
5512 #   %G-W%V           => 2007-W47                  Week date, reduced accuracy, specific week (extended)
5513 #   %H%M%S           => 083748                    Local time (basic)
5514 #   %T               => 08:37:48                  Local time (extended)
5515 #   %H%M             => 0837                      Local time, reduced accuracy, specific minute (basic)
5516 #   %H:%M            => 08:37                     Local time, reduced accuracy, specific minute (extended)
5517 #   %H               => 08                        Local time, reduced accuracy, specific hour
5518 #   %H%M%S,%L        => 083748,000                Local time with decimal fraction, comma as decimal sign (basic)
5519 #   %T,%L            => 08:37:48,000              Local time with decimal fraction, comma as decimal sign (extended)
5520 #   %H%M%S.%L        => 083748.000                Local time with decimal fraction, full stop as decimal sign (basic)
5521 #   %T.%L            => 08:37:48.000              Local time with decimal fraction, full stop as decimal sign (extended)
5522 #   %H%M%S%z         => 083748-0600               Local time and the difference from UTC (basic)
5523 #   %T%:z            => 08:37:48-06:00            Local time and the difference from UTC (extended)
5524 #   %Y%m%dT%H%M%S%z  => 20071119T083748-0600      Date and time of day for calendar date (basic)
5525 #   %FT%T%:z         => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
5526 #   %Y%jT%H%M%S%z    => 2007323T083748-0600       Date and time of day for ordinal date (basic)
5527 #   %Y-%jT%T%:z      => 2007-323T08:37:48-06:00   Date and time of day for ordinal date (extended)
5528 #   %GW%V%uT%H%M%S%z => 2007W471T083748-0600      Date and time of day for week date (basic)
5529 #   %G-W%V-%uT%T%:z  => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
5530 #   %Y%m%dT%H%M      => 20071119T0837             Calendar date and local time (basic)
5531 #   %FT%R            => 2007-11-19T08:37          Calendar date and local time (extended)
5532 #   %Y%jT%H%MZ       => 2007323T0837Z             Ordinal date and UTC of day (basic)
5533 #   %Y-%jT%RZ        => 2007-323T08:37Z           Ordinal date and UTC of day (extended)
5534 #   %GW%V%uT%H%M%z   => 2007W471T0837-0600        Week date and local time and difference from UTC (basic)
5535 #   %G-W%V-%uT%R%:z  => 2007-W47-1T08:37-06:00    Week date and local time and difference from UTC (extended)
5536 def strftime( string ); ''; end
5537 end
5538 
5539 ##
5540 # ::RubyVM   
5541 class RubyVM < Object
5542 class Env < Object
5543 end
5544 
5545 end
5546 
5547 ##
5548 # Threads are the Ruby implementation for a concurrent programming model.
5549 # 
5550 # Programs that require multiple threads of execution are a perfect
5551 # candidate for Ruby's Thread class.
5552 # 
5553 # For example, we can create a new thread separate from the main thread's
5554 # execution using ::new.
5555 # 
5556 #     thr = Thread.new { puts "Whats the big deal" }
5557 # 
5558 # Then we are able to pause the execution of the main thread and allow
5559 # our new thread to finish, using #join:
5560 # 
5561 #     thr.join #=> "Whats the big deal"
5562 # 
5563 # If we don't call +thr.join+ before the main thread terminates, then all
5564 # other threads including +thr+ will be killed.
5565 # 
5566 # Alternatively, you can use an array for handling multiple threads at
5567 # once, like in the following example:
5568 # 
5569 #     threads = []
5570 #     threads << Thread.new { puts "Whats the big deal" }
5571 #     threads << Thread.new { 3.times { puts "Threads are fun!" } }
5572 # 
5573 # After creating a few threads we wait for them all to finish
5574 # consecutively.
5575 # 
5576 #     threads.each { |thr| thr.join }
5577 # 
5578 # === Thread initialization
5579 # 
5580 # In order to create new threads, Ruby provides ::new, ::start, and
5581 # ::fork. A block must be provided with each of these methods, otherwise
5582 # a ThreadError will be raised.
5583 # 
5584 # When subclassing the Thread class, the +initialize+ method of your
5585 # subclass will be ignored by ::start and ::fork. Otherwise, be sure to
5586 # call super in your +initialize+ method.
5587 # 
5588 # === Thread termination
5589 # 
5590 # For terminating threads, Ruby provides a variety of ways to do this.
5591 # 
5592 # The class method ::kill, is meant to exit a given thread:
5593 # 
5594 #     thr = Thread.new { ... }
5595 #     Thread.kill(thr) # sends exit() to thr
5596 # 
5597 # Alternatively, you can use the instance method #exit, or any of its
5598 # aliases #kill or #terminate.
5599 # 
5600 #     thr.exit
5601 # 
5602 # === Thread status
5603 # 
5604 # Ruby provides a few instance methods for querying the state of a given
5605 # thread. To get a string with the current thread's state use #status
5606 # 
5607 #     thr = Thread.new { sleep }
5608 #     thr.status # => "sleep"
5609 #     thr.exit
5610 #     thr.status # => false
5611 # 
5612 # You can also use #alive? to tell if the thread is running or sleeping,
5613 # and #stop? if the thread is dead or sleeping.
5614 # 
5615 # === Thread variables and scope
5616 # 
5617 # Since threads are created with blocks, the same rules apply to other
5618 # Ruby blocks for variable scope. Any local variables created within this
5619 # block are accessible to only this thread.
5620 # 
5621 # ==== Fiber-local vs. Thread-local
5622 # 
5623 # Each fiber has its own bucket for Thread#[] storage. When you set a
5624 # new fiber-local it is only accessible within this Fiber. To illustrate:
5625 # 
5626 #     Thread.new {
5627 #       Thread.current[:foo] = "bar"
5628 #       Fiber.new {
5629 #         p Thread.current[:foo] # => nil
5630 #       }.resume
5631 #     }.join
5632 # 
5633 # This example uses #[] for getting and #[]= for setting fiber-locals,
5634 # you can also use #keys to list the fiber-locals for a given
5635 # thread and #key? to check if a fiber-local exists.
5636 # 
5637 # When it comes to thread-locals, they are accessible within the entire
5638 # scope of the thread. Given the following example:
5639 # 
5640 #     Thread.new{
5641 #       Thread.current.thread_variable_set(:foo, 1)
5642 #       p Thread.current.thread_variable_get(:foo) # => 1
5643 #       Fiber.new{
5644 #         Thread.current.thread_variable_set(:foo, 2)
5645 #         p Thread.current.thread_variable_get(:foo) # => 2
5646 #       }.resume
5647 #       p Thread.current.thread_variable_get(:foo)   # => 2
5648 #     }.join
5649 # 
5650 # You can see that the thread-local +:foo+ carried over into the fiber
5651 # and was changed to +2+ by the end of the thread.
5652 # 
5653 # This example makes use of #thread_variable_set to create new
5654 # thread-locals, and #thread_variable_get to reference them.
5655 # 
5656 # There is also #thread_variables to list all thread-locals, and
5657 # #thread_variable? to check if a given thread-local exists.
5658 # 
5659 # === Exception handling
5660 # 
5661 # Any thread can raise an exception using the #raise instance method,
5662 # which operates similarly to Kernel#raise.
5663 # 
5664 # However, it's important to note that an exception that occurs in any
5665 # thread except the main thread depends on #abort_on_exception. This
5666 # option is +false+ by default, meaning that any unhandled exception will
5667 # cause the thread to terminate silently when waited on by either #join
5668 # or #value. You can change this default by either #abort_on_exception=
5669 # +true+ or setting $DEBUG to +true+.
5670 # 
5671 # With the addition of the class method ::handle_interrupt, you can now
5672 # handle exceptions asynchronously with threads.
5673 # 
5674 # === Scheduling
5675 # 
5676 # Ruby provides a few ways to support scheduling threads in your program.
5677 # 
5678 # The first way is by using the class method ::stop, to put the current
5679 # running thread to sleep and schedule the execution of another thread.
5680 # 
5681 # Once a thread is asleep, you can use the instance method #wakeup to
5682 # mark your thread as eligible for scheduling.
5683 # 
5684 # You can also try ::pass, which attempts to pass execution to another
5685 # thread but is dependent on the OS whether a running thread will switch
5686 # or not. The same goes for #priority, which lets you hint to the thread
5687 # scheduler which threads you want to take precedence when passing
5688 # execution. This method is also dependent on the OS and may be ignored
5689 # on some platforms.
5690 class Thread < Object
5691 class Backtrace < Object
5692 class Location < Object
5693 end
5694 
5695 end
5696 
5697 ##
5698 # Establishes _proc_ on _thr_ as the handler for tracing, or
5699 # disables tracing if the parameter is +nil+.
5700 # 
5701 # See Kernel#set_trace_func.
5702 def set_trace_func(proc); end
5703 ##
5704 # Adds _proc_ as a handler for tracing.
5705 # 
5706 # See Thread#set_trace_func and Kernel#set_trace_func.
5707 def add_trace_func(proc); Proc.new; end
5708 ##
5709 # Creates a new thread executing the given block.
5710 # 
5711 # Any +args+ given to ::new will be passed to the block:
5712 # 
5713 #     arr = []
5714 #     a, b, c = 1, 2, 3
5715 #     Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join
5716 #     arr #=> [1, 2, 3]
5717 # 
5718 # A ThreadError exception is raised if ::new is called without a block.
5719 # 
5720 # If you're going to subclass Thread, be sure to call super in your
5721 # +initialize+ method, otherwise a ThreadError will be raised.
5722 def self.new(&block); end
5723 ##
5724 # Basically the same as ::new. However, if class Thread is subclassed, then
5725 # calling +start+ in that subclass will not invoke the subclass's
5726 # +initialize+ method.
5727 def self.start(); Thread.new; end
5728 ##
5729 # Basically the same as ::new. However, if class Thread is subclassed, then
5730 # calling +start+ in that subclass will not invoke the subclass's
5731 # +initialize+ method.
5732 def self.fork(); Thread.new; end
5733 ##
5734 # Returns the main thread.
5735 def self.main; Thread.new; end
5736 ##
5737 # Returns the currently executing thread.
5738 # 
5739 #    Thread.current   #=> #<Thread:0x401bdf4c run>
5740 def self.current; Thread.new; end
5741 ##
5742 # Stops execution of the current thread, putting it into a ``sleep'' state,
5743 # and schedules execution of another thread.
5744 # 
5745 #    a = Thread.new { print "a"; Thread.stop; print "c" }
5746 #    sleep 0.1 while a.status!='sleep'
5747 #    print "b"
5748 #    a.run
5749 #    a.join
5750 #    #=> "abc"
5751 def self.stop; end
5752 ##
5753 # Causes the given +thread+ to exit, see also Thread::exit.
5754 # 
5755 #    count = 0
5756 #    a = Thread.new { loop { count += 1 } }
5757 #    sleep(0.1)       #=> 0
5758 #    Thread.kill(a)   #=> #<Thread:0x401b3d30 dead>
5759 #    count            #=> 93947
5760 #    a.alive?         #=> false
5761 def self.kill(thread); nil || Thread.new; end
5762 ##
5763 # Terminates the currently running thread and schedules another thread to be
5764 # run.
5765 # 
5766 # If this thread is already marked to be killed, ::exit returns the Thread.
5767 # 
5768 # If this is the main thread, or the last  thread, exit the process.
5769 def self.exit; nil || Thread.new; end
5770 ##
5771 # Give the thread scheduler a hint to pass execution to another thread.
5772 # A running thread may or may not switch, it depends on OS and processor.
5773 def self.pass; end
5774 ##
5775 # Returns an array of Thread objects for all threads that are either runnable
5776 # or stopped.
5777 # 
5778 #    Thread.new { sleep(200) }
5779 #    Thread.new { 1000000.times {|i| i*i } }
5780 #    Thread.new { Thread.stop }
5781 #    Thread.list.each {|t| p t}
5782 # 
5783 # This will produce:
5784 # 
5785 #    #<Thread:0x401b3e84 sleep>
5786 #    #<Thread:0x401b3f38 run>
5787 #    #<Thread:0x401b3fb0 sleep>
5788 #    #<Thread:0x401bdf4c run>
5789 def self.list; []; end
5790 ##
5791 # Returns the status of the global ``abort on exception'' condition.
5792 # 
5793 # The default is +false+.
5794 # 
5795 # When set to +true+, all threads will abort (the process will
5796 # <code>exit(0)</code>) if an exception is raised in any thread.
5797 # 
5798 # Can also be specified by the global $DEBUG flag or command line option
5799 # +-d+.
5800 # 
5801 # See also ::abort_on_exception=.
5802 # 
5803 # There is also an instance level method to set this for a specific thread,
5804 # see #abort_on_exception.
5805 def self.abort_on_exception; true || false; end
5806 ##
5807 # When set to +true+, all threads will abort if an exception is raised.
5808 # Returns the new state.
5809 # 
5810 #    Thread.abort_on_exception = true
5811 #    t1 = Thread.new do
5812 #      puts  "In new thread"
5813 #      raise "Exception from thread"
5814 #    end
5815 #    sleep(1)
5816 #    puts "not reached"
5817 # 
5818 # This will produce:
5819 # 
5820 #    In new thread
5821 #    prog.rb:4: Exception from thread (RuntimeError)
5822 #     from prog.rb:2:in `initialize'
5823 #     from prog.rb:2:in `new'
5824 #     from prog.rb:2
5825 # 
5826 # See also ::abort_on_exception.
5827 # 
5828 # There is also an instance level method to set this for a specific thread,
5829 # see #abort_on_exception=.
5830 def self.abort_on_exception= boolean; true || false; end
5831 ##
5832 # Returns the thread debug level.  Available only if compiled with
5833 # THREAD_DEBUG=-1.
5834 def self.DEBUG; 0; end
5835 ##
5836 # Sets the thread debug level.  Available only if compiled with
5837 # THREAD_DEBUG=-1.
5838 def self.DEBUG= num; end
5839 ##
5840 # Changes asynchronous interrupt timing.
5841 # 
5842 # _interrupt_ means asynchronous event and corresponding procedure
5843 # by Thread#raise, Thread#kill, signal trap (not supported yet)
5844 # and main thread termination (if main thread terminates, then all
5845 # other thread will be killed).
5846 # 
5847 # The given +hash+ has pairs like <code>ExceptionClass =>
5848 # :TimingSymbol</code>. Where the ExceptionClass is the interrupt handled by
5849 # the given block. The TimingSymbol can be one of the following symbols:
5850 # 
5851 # [+:immediate+]   Invoke interrupts immediately.
5852 # [+:on_blocking+] Invoke interrupts while _BlockingOperation_.
5853 # [+:never+]       Never invoke all interrupts.
5854 # 
5855 # _BlockingOperation_ means that the operation will block the calling thread,
5856 # such as read and write.  On CRuby implementation, _BlockingOperation_ is any
5857 # operation executed without GVL.
5858 # 
5859 # Masked asynchronous interrupts are delayed until they are enabled.
5860 # This method is similar to sigprocmask(3).
5861 # 
5862 # === NOTE
5863 # 
5864 # Asynchronous interrupts are difficult to use.
5865 # 
5866 # If you need to communicate between threads, please consider to use another way such as Queue.
5867 # 
5868 # Or use them with deep understanding about this method.
5869 # 
5870 # === Usage
5871 # 
5872 # In this example, we can guard from Thread#raise exceptions.
5873 # 
5874 # Using the +:never+ TimingSymbol the RuntimeError exception will always be
5875 # ignored in the first block of the main thread. In the second
5876 # ::handle_interrupt block we can purposefully handle RuntimeError exceptions.
5877 # 
5878 #   th = Thread.new do
5879 #     Thead.handle_interrupt(RuntimeError => :never) {
5880 #       begin
5881 #         # You can write resource allocation code safely.
5882 #         Thread.handle_interrupt(RuntimeError => :immediate) {
5883 #           # ...
5884 #         }
5885 #       ensure
5886 #         # You can write resource deallocation code safely.
5887 #       end
5888 #     }
5889 #   end
5890 #   Thread.pass
5891 #   # ...
5892 #   th.raise "stop"
5893 # 
5894 # While we are ignoring the RuntimeError exception, it's safe to write our
5895 # resource allocation code. Then, the ensure block is where we can safely
5896 # deallocate your resources.
5897 # 
5898 # ==== Guarding from TimeoutError
5899 # 
5900 # In the next example, we will guard from the TimeoutError exception. This
5901 # will help prevent from leaking resources when TimeoutError exceptions occur
5902 # during normal ensure clause. For this example we use the help of the
5903 # standard library Timeout, from lib/timeout.rb
5904 # 
5905 #   require 'timeout'
5906 #   Thread.handle_interrupt(TimeoutError => :never) {
5907 #     timeout(10){
5908 #       # TimeoutError doesn't occur here
5909 #       Thread.handle_interrupt(TimeoutError => :on_blocking) {
5910 #         # possible to be killed by TimeoutError
5911 #         # while blocking operation
5912 #       }
5913 #       # TimeoutError doesn't occur here
5914 #     }
5915 #   }
5916 # 
5917 # In the first part of the +timeout+ block, we can rely on TimeoutError being
5918 # ignored. Then in the <code>TimeoutError => :on_blocking</code> block, any
5919 # operation that will block the calling thread is susceptible to a
5920 # TimeoutError exception being raised.
5921 # 
5922 # ==== Stack control settings
5923 # 
5924 # It's possible to stack multiple levels of ::handle_interrupt blocks in order
5925 # to control more than one ExceptionClass and TimingSymbol at a time.
5926 # 
5927 #   Thread.handle_interrupt(FooError => :never) {
5928 #     Thread.handle_interrupt(BarError => :never) {
5929 #        # FooError and BarError are prohibited.
5930 #     }
5931 #   }
5932 # 
5933 # ==== Inheritance with ExceptionClass
5934 # 
5935 # All exceptions inherited from the ExceptionClass parameter will be considered.
5936 # 
5937 #   Thread.handle_interrupt(Exception => :never) {
5938 #     # all exceptions inherited from Exception are prohibited.
5939 #   }
5940 def self.handle_interrupt(hash, &block); Object.new; end
5941 ##
5942 # Returns whether or not the asynchronous queue is empty.
5943 # 
5944 # Since Thread::handle_interrupt can be used to defer asynchronous events.
5945 # This method can be used to determine if there are any deferred events.
5946 # 
5947 # If you find this method returns true, then you may finish +:never+ blocks.
5948 # 
5949 # For example, the following method processes deferred asynchronous events
5950 # immediately.
5951 # 
5952 #   def Thread.kick_interrupt_immediately
5953 #     Thread.handle_interrupt(Object => :immediate) {
5954 #       Thread.pass
5955 #     }
5956 #   end
5957 # 
5958 # If +error+ is given, then check only for +error+ type deferred events.
5959 # 
5960 # === Usage
5961 # 
5962 #   th = Thread.new{
5963 #     Thread.handle_interrupt(RuntimeError => :on_blocking){
5964 #       while true
5965 #         ...
5966 #         # reach safe point to invoke interrupt
5967 #         if Thread.pending_interrupt?
5968 #           Thread.handle_interrupt(Object => :immediate){}
5969 #         end
5970 #         ...
5971 #       end
5972 #     }
5973 #   }
5974 #   ...
5975 #   th.raise # stop thread
5976 # 
5977 # This example can also be written as the following, which you should use to
5978 # avoid asynchronous interrupts.
5979 # 
5980 #   flag = true
5981 #   th = Thread.new{
5982 #     Thread.handle_interrupt(RuntimeError => :on_blocking){
5983 #       while true
5984 #         ...
5985 #         # reach safe point to invoke interrupt
5986 #         break if flag == false
5987 #         ...
5988 #       end
5989 #     }
5990 #   }
5991 #   ...
5992 #   flag = false # stop thread
5993 def self.pending_interrupt?(error = null); true || false; end
5994 ##
5995 # Raises an exception from the given thread. The caller does not have to be
5996 # +thr+. See Kernel#raise for more information.
5997 # 
5998 #    Thread.abort_on_exception = true
5999 #    a = Thread.new { sleep(200) }
6000 #    a.raise("Gotcha")
6001 # 
6002 # This will produce:
6003 # 
6004 #    prog.rb:3: Gotcha (RuntimeError)
6005 #     from prog.rb:2:in `initialize'
6006 #     from prog.rb:2:in `new'
6007 #     from prog.rb:2
6008 def raise; end
6009 ##
6010 # The calling thread will suspend execution and run this +thr+.
6011 # 
6012 # Does not return until +thr+ exits or until the given +limit+ seconds have
6013 # passed.
6014 # 
6015 # If the time limit expires, +nil+ will be returned, otherwise this +thr+ is
6016 # returned.
6017 # 
6018 # Any threads not joined will be killed when the main program exits.
6019 # 
6020 # If +thr+ had previously raised an exception and the ::abort_on_exception or
6021 # $DEBUG flags are not set, (so the exception has not yet been processed), it
6022 # will be processed at this time.
6023 # 
6024 #    a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
6025 #    x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
6026 #    x.join # Let x thread finish, a will be killed on exit.
6027 #    #=> "axyz"
6028 # 
6029 # The following example illustrates the +limit+ parameter.
6030 # 
6031 #    y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
6032 #    puts "Waiting" until y.join(0.15)
6033 # 
6034 # This will produce:
6035 # 
6036 #    tick...
6037 #    Waiting
6038 #    tick...
6039 #    Waiting
6040 #    tick...
6041 #    tick...
6042 def join; Thread.new; end
6043 ##
6044 # Waits for +thr+ to complete, using #join, and returns its value.
6045 # 
6046 #    a = Thread.new { 2 + 2 }
6047 #    a.value   #=> 4
6048 def value; Object.new; end
6049 ##
6050 # Terminates +thr+ and schedules another thread to be run.
6051 # 
6052 # If this thread is already marked to be killed, #exit returns the Thread.
6053 # 
6054 # If this is the main thread, or the last thread, exits the process.
6055 def terminate; nil || Thread.new; end
6056 ##
6057 # Wakes up +thr+, making it eligible for scheduling.
6058 # 
6059 #    a = Thread.new { puts "a"; Thread.stop; puts "c" }
6060 #    sleep 0.1 while a.status!='sleep'
6061 #    puts "Got here"
6062 #    a.run
6063 #    a.join
6064 # 
6065 # This will produce:
6066 # 
6067 #    a
6068 #    Got here
6069 #    c
6070 # 
6071 # See also the instance method #wakeup.
6072 def run; Thread.new; end
6073 ##
6074 # Marks a given thread as eligible for scheduling, however it may still
6075 # remain blocked on I/O.
6076 # 
6077 # *Note:* This does not invoke the scheduler, see #run for more information.
6078 # 
6079 #    c = Thread.new { Thread.stop; puts "hey!" }
6080 #    sleep 0.1 while c.status!='sleep'
6081 #    c.wakeup
6082 #    c.join
6083 #    #=> "hey!"
6084 def wakeup; Thread.new; end
6085 ##
6086 # Attribute Reference---Returns the value of a fiber-local variable (current thread's root fiber
6087 # if not explicitely inside a Fiber), using either a symbol or a string name.
6088 # If the specified variable does not exist, returns +nil+.
6089 # 
6090 #    [
6091 #      Thread.new { Thread.current["name"] = "A" },
6092 #      Thread.new { Thread.current[:name]  = "B" },
6093 #      Thread.new { Thread.current["name"] = "C" }
6094 #    ].each do |th|
6095 #      th.join
6096 #      puts "#{th.inspect}: #{th[:name]}"
6097 #    end
6098 # 
6099 # This will produce:
6100 # 
6101 #    #<Thread:0x00000002a54220 dead>: A
6102 #    #<Thread:0x00000002a541a8 dead>: B
6103 #    #<Thread:0x00000002a54130 dead>: C
6104 # 
6105 # Thread#[] and Thread#[]= are not thread-local but fiber-local.
6106 # This confusion did not exist in Ruby 1.8 because
6107 # fibers were only available since Ruby 1.9.
6108 # Ruby 1.9 chooses that the methods behaves fiber-local to save
6109 # following idiom for dynamic scope.
6110 # 
6111 #   def meth(newvalue)
6112 #     begin
6113 #       oldvalue = Thread.current[:name]
6114 #       Thread.current[:name] = newvalue
6115 #       yield
6116 #     ensure
6117 #       Thread.current[:name] = oldvalue
6118 #     end
6119 #   end
6120 # 
6121 # The idiom may not work as dynamic scope if the methods are thread-local
6122 # and a given block switches fiber.
6123 # 
6124 #   f = Fiber.new {
6125 #     meth(1) {
6126 #       Fiber.yield
6127 #     }
6128 #   }
6129 #   meth(2) {
6130 #     f.resume
6131 #   }
6132 #   f.resume
6133 #   p Thread.current[:name]
6134 #   #=> nil if fiber-local
6135 #   #=> 2 if thread-local (The value 2 is leaked to outside of meth method.)
6136 # 
6137 # For thread-local variables, please see #thread_variable_get and
6138 # #thread_variable_set.
6139 def []; Object.new || nil; end
6140 ##
6141 # Attribute Assignment---Sets or creates the value of a fiber-local variable,
6142 # using either a symbol or a string.
6143 # 
6144 # See also Thread#[].
6145 # 
6146 # For thread-local variables, please see #thread_variable_set and
6147 # #thread_variable_get.
6148 def []=; Object.new; end
6149 ##
6150 # Returns +true+ if the given string (or symbol) exists as a fiber-local
6151 # variable.
6152 # 
6153 #    me = Thread.current
6154 #    me[:oliver] = "a"
6155 #    me.key?(:oliver)    #=> true
6156 #    me.key?(:stanley)   #=> false
6157 def key?(sym); true || false; end
6158 ##
6159 # Returns an an array of the names of the fiber-local variables (as Symbols).
6160 # 
6161 #    thr = Thread.new do
6162 #      Thread.current[:cat] = 'meow'
6163 #      Thread.current["dog"] = 'woof'
6164 #    end
6165 #    thr.join   #=> #<Thread:0x401b3f10 dead>
6166 #    thr.keys   #=> [:dog, :cat]
6167 def keys; []; end
6168 ##
6169 # Returns the priority of <i>thr</i>. Default is inherited from the
6170 # current thread which creating the new thread, or zero for the
6171 # initial main thread; higher-priority thread will run more frequently
6172 # than lower-priority threads (but lower-priority threads can also run).
6173 # 
6174 # This is just hint for Ruby thread scheduler.  It may be ignored on some
6175 # platform.
6176 # 
6177 #    Thread.current.priority   #=> 0
6178 def priority; 0; end
6179 ##
6180 # Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads
6181 # will run more frequently than lower-priority threads (but lower-priority
6182 # threads can also run).
6183 # 
6184 # This is just hint for Ruby thread scheduler.  It may be ignored on some
6185 # platform.
6186 # 
6187 #    count1 = count2 = 0
6188 #    a = Thread.new do
6189 #          loop { count1 += 1 }
6190 #        end
6191 #    a.priority = -1
6192 # 
6193 #    b = Thread.new do
6194 #          loop { count2 += 1 }
6195 #        end
6196 #    b.priority = -2
6197 #    sleep 1   #=> 1
6198 #    count1    #=> 622504
6199 #    count2    #=> 5832
6200 def priority= integer; Thread.new; end
6201 ##
6202 # Returns the status of +thr+.
6203 # 
6204 # [<tt>"sleep"</tt>]
6205 #     Returned if this thread is sleeping or waiting on I/O
6206 # [<tt>"run"</tt>]
6207 #     When this thread is executing
6208 # [<tt>"aborting"</tt>]
6209 #     If this thread is aborting
6210 # [+false+]
6211 #     When this thread is terminated normally
6212 # [+nil+]
6213 #     If terminated with an exception.
6214 # 
6215 #    a = Thread.new { raise("die now") }
6216 #    b = Thread.new { Thread.stop }
6217 #    c = Thread.new { Thread.exit }
6218 #    d = Thread.new { sleep }
6219 #    d.kill                  #=> #<Thread:0x401b3678 aborting>
6220 #    a.status                #=> nil
6221 #    b.status                #=> "sleep"
6222 #    c.status                #=> false
6223 #    d.status                #=> "aborting"
6224 #    Thread.current.status   #=> "run"
6225 # 
6226 # See also the instance methods #alive? and #stop?
6227 def status; '' || false || nil; end
6228 ##
6229 # Returns the value of a thread local variable that has been set.  Note that
6230 # these are different than fiber local values.  For fiber local values,
6231 # please see Thread#[] and Thread#[]=.
6232 # 
6233 # Thread local values are carried along with threads, and do not respect
6234 # fibers.  For example:
6235 # 
6236 #   Thread.new {
6237 #     Thread.current.thread_variable_set("foo", "bar") # set a thread local
6238 #     Thread.current["foo"] = "bar"                    # set a fiber local
6239 # 
6240 #     Fiber.new {
6241 #       Fiber.yield [
6242 #         Thread.current.thread_variable_get("foo"), # get the thread local
6243 #         Thread.current["foo"],                     # get the fiber local
6244 #       ]
6245 #     }.resume
6246 #   }.join.value # => ['bar', nil]
6247 # 
6248 # The value "bar" is returned for the thread local, where nil is returned
6249 # for the fiber local.  The fiber is executed in the same thread, so the
6250 # thread local values are available.
6251 # 
6252 # See also Thread#[]
6253 def thread_variable_get(key); Object.new || nil; end
6254 ##
6255 # Sets a thread local with +key+ to +value+.  Note that these are local to
6256 # threads, and not to fibers.  Please see Thread#thread_variable_get and
6257 # Thread#[] for more information.
6258 def thread_variable_set(key, value); end
6259 ##
6260 # Returns an an array of the names of the thread-local variables (as Symbols).
6261 # 
6262 #    thr = Thread.new do
6263 #      Thread.current.thread_variable_set(:cat, 'meow')
6264 #      Thread.current.thread_variable_set("dog", 'woof')
6265 #    end
6266 #    thr.join               #=> #<Thread:0x401b3f10 dead>
6267 #    thr.thread_variables   #=> [:dog, :cat]
6268 # 
6269 # Note that these are not fiber local variables.  Please see Thread#[] and
6270 # Thread#thread_variable_get for more details.
6271 def thread_variables; []; end
6272 ##
6273 # Returns +true+ if the given string (or symbol) exists as a thread-local
6274 # variable.
6275 # 
6276 #    me = Thread.current
6277 #    me.thread_variable_set(:oliver, "a")
6278 #    me.thread_variable?(:oliver)    #=> true
6279 #    me.thread_variable?(:stanley)   #=> false
6280 # 
6281 # Note that these are not fiber local variables.  Please see Thread#[] and
6282 # Thread#thread_variable_get for more details.
6283 def thread_variable?(key); true || false; end
6284 ##
6285 # Returns +true+ if +thr+ is running or sleeping.
6286 # 
6287 #    thr = Thread.new { }
6288 #    thr.join                #=> #<Thread:0x401b3fb0 dead>
6289 #    Thread.current.alive?   #=> true
6290 #    thr.alive?              #=> false
6291 # 
6292 # See also #stop? and #status.
6293 def alive?; true || false; end
6294 ##
6295 # Returns +true+ if +thr+ is dead or sleeping.
6296 # 
6297 #    a = Thread.new { Thread.stop }
6298 #    b = Thread.current
6299 #    a.stop?   #=> true
6300 #    b.stop?   #=> false
6301 # 
6302 # See also #alive? and #status.
6303 def stop?; true || false; end
6304 ##
6305 # Returns the safe level in effect for <i>thr</i>. Setting thread-local safe
6306 # levels can help when implementing sandboxes which run insecure code.
6307 # 
6308 #    thr = Thread.new { $SAFE = 3; sleep }
6309 #    Thread.current.safe_level   #=> 0
6310 #    thr.safe_level              #=> 3
6311 def safe_level; 0; end
6312 ##
6313 # Returns the ThreadGroup which contains the given thread, or returns +nil+
6314 # if +thr+ is not a member of any group.
6315 # 
6316 #    Thread.main.group   #=> #<ThreadGroup:0x4029d914>
6317 def group; ThreadGroup.new || nil; end
6318 ##
6319 # Returns the current backtrace of the target thread.
6320 def backtrace; []; end
6321 ##
6322 # Returns the execution stack for the target thread---an array containing
6323 # backtrace location objects.
6324 # 
6325 # See Thread::Backtrace::Location for more information.
6326 # 
6327 # This method behaves similarly to Kernel#caller_locations except it applies
6328 # to a specific thread.
6329 def backtrace_locations(); [] || nil; end
6330 ##
6331 # Dump the name, id, and status of _thr_ to a string.
6332 def inspect; ''; end
6333 end
6334 
6335 class Object < BasicObject
6336 include Kernel
6337 ##
6338 # Looks up the named method as a receiver in <i>obj</i>, returning a
6339 # <code>Method</code> object (or raising <code>NameError</code>). The
6340 # <code>Method</code> object acts as a closure in <i>obj</i>'s object
6341 # instance, so instance variables and the value of <code>self</code>
6342 # remain available.
6343 # 
6344 #    class Demo
6345 #      def initialize(n)
6346 #        @iv = n
6347 #      end
6348 #      def hello()
6349 #        "Hello, @iv = #{@iv}"
6350 #      end
6351 #    end
6352 # 
6353 #    k = Demo.new(99)
6354 #    m = k.method(:hello)
6355 #    m.call   #=> "Hello, @iv = 99"
6356 # 
6357 #    l = Demo.new('Fred')
6358 #    m = l.method("hello")
6359 #    m.call   #=> "Hello, @iv = Fred"
6360 def method(sym); Method.new; end
6361 ##
6362 # Similar to _method_, searches public method only.
6363 def public_method(sym); Method.new; end
6364 ##
6365 # Defines a singleton method in the receiver. The _method_
6366 # parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
6367 # If a block is specified, it is used as the method body.
6368 # 
6369 #    class A
6370 #      class << self
6371 #        def class_name
6372 #          to_s
6373 #        end
6374 #      end
6375 #    end
6376 #    A.define_singleton_method(:who_am_i) do
6377 #      "I am: #{class_name}"
6378 #    end
6379 #    A.who_am_i   # ==> "I am: A"
6380 # 
6381 #    guy = "Bob"
6382 #    guy.define_singleton_method(:hello) { "#{self}: Hello there!" }
6383 #    guy.hello    #=>  "Bob: Hello there!"
6384 def define_singleton_method(symbol, method); Proc.new; end
6385 ##
6386 # Invokes the method identified by _symbol_, passing it any
6387 # arguments specified. You can use <code>__send__</code> if the name
6388 # +send+ clashes with an existing method in _obj_.
6389 # When the method is identified by a string, the string is converted
6390 # to a symbol.
6391 # 
6392 #    class Klass
6393 #      def hello(*args)
6394 #        "Hello " + args.join(' ')
6395 #      end
6396 #    end
6397 #    k = Klass.new
6398 #    k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"
6399 def send(symbol , args=0); Object.new; end
6400 ##
6401 # Invokes the method identified by _symbol_, passing it any
6402 # arguments specified. You can use <code>__send__</code> if the name
6403 # +send+ clashes with an existing method in _obj_.
6404 # When the method is identified by a string, the string is converted
6405 # to a symbol.
6406 # 
6407 #    class Klass
6408 #      def hello(*args)
6409 #        "Hello " + args.join(' ')
6410 #      end
6411 #    end
6412 #    k = Klass.new
6413 #    k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"
6414 def __send__(symbol , args=0); Object.new; end
6415 ##
6416 # Invokes the method identified by _symbol_, passing it any
6417 # arguments specified. Unlike send, public_send calls public
6418 # methods only.
6419 # When the method is identified by a string, the string is converted
6420 # to a symbol.
6421 # 
6422 #    1.public_send(:puts, "hello")  # causes NoMethodError
6423 def public_send(symbol , args=0); Object.new; end
6424 ##
6425 # Adds to _obj_ the instance methods from each module given as a
6426 # parameter.
6427 # 
6428 #    module Mod
6429 #      def hello
6430 #        "Hello from Mod.\n"
6431 #      end
6432 #    end
6433 # 
6434 #    class Klass
6435 #      def hello
6436 #        "Hello from Klass.\n"
6437 #      end
6438 #    end
6439 # 
6440 #    k = Klass.new
6441 #    k.hello         #=> "Hello from Klass.\n"
6442 #    k.extend(Mod)   #=> #<Klass:0x401b3bc8>
6443 #    k.hello         #=> "Hello from Mod.\n"
6444 def extend(); Object.new; end
6445 ##
6446 # Returns an integer identifier for +obj+.
6447 # 
6448 # The same number will be returned on all calls to +id+ for a given object,
6449 # and no two active objects will share an id.
6450 # 
6451 # Object#object_id is a different concept from the +:name+ notation, which
6452 # returns the symbol id of +name+.
6453 # 
6454 # Replaces the deprecated Object#id.
6455 def __id__; 0; end
6456 ##
6457 # Returns an integer identifier for +obj+.
6458 # 
6459 # The same number will be returned on all calls to +id+ for a given object,
6460 # and no two active objects will share an id.
6461 # 
6462 # Object#object_id is a different concept from the +:name+ notation, which
6463 # returns the symbol id of +name+.
6464 # 
6465 # Replaces the deprecated Object#id.
6466 def object_id; 0; end
6467 ##
6468 # Returns +true+ if _obj_ responds to the given method.  Private and
6469 # protected methods are included in the search only if the optional
6470 # second parameter evaluates to +true+.
6471 # 
6472 # If the method is not implemented,
6473 # as Process.fork on Windows, File.lchmod on GNU/Linux, etc.,
6474 # false is returned.
6475 # 
6476 # If the method is not defined, <code>respond_to_missing?</code>
6477 # method is called and the result is returned.
6478 # 
6479 # When the method name parameter is given as a string, the string is
6480 # converted to a symbol.
6481 def respond_to?(symbol, include_all=false); true || false; end
6482 ##
6483 # DO NOT USE THIS DIRECTLY.
6484 # 
6485 # Hook method to return whether the _obj_ can respond to _id_ method
6486 # or not.
6487 # 
6488 # When the method name parameter is given as a string, the string is
6489 # converted to a symbol.
6490 # 
6491 # See #respond_to?.
6492 def respond_to_missing?(symbol, include_all); true || false; end
6493 ##
6494 # Case Equality -- For class Object, effectively the same as calling
6495 # <code>#==</code>, but typically overridden by descendants to provide
6496 # meaningful semantics in +case+ statements.
6497 def ===; true || false; end
6498 ##
6499 # Pattern Match---Overridden by descendants (notably
6500 # <code>Regexp</code> and <code>String</code>) to provide meaningful
6501 # pattern-match semantics.
6502 def =~; end
6503 ##
6504 # Returns true if two objects do not match (using the <i>=~</i>
6505 # method), otherwise false.
6506 def !~; true || false; end
6507 ##
6508 # Equality --- At the <code>Object</code> level, <code>==</code> returns
6509 # <code>true</code> only if +obj+ and +other+ are the same object.
6510 # Typically, this method is overridden in descendant classes to provide
6511 # class-specific meaning.
6512 # 
6513 # Unlike <code>==</code>, the <code>equal?</code> method should never be
6514 # overridden by subclasses as it is used to determine object identity
6515 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
6516 # same object as <code>b</code>):
6517 # 
6518 #   obj = "a"
6519 #   other = obj.dup
6520 # 
6521 #   a == other      #=> true
6522 #   a.equal? other  #=> false
6523 #   a.equal? a      #=> true
6524 # 
6525 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
6526 # +other+ refer to the same hash key.  This is used by Hash to test members
6527 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
6528 # is synonymous with <code>==</code>.  Subclasses normally continue this
6529 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
6530 # method, but there are exceptions.  <code>Numeric</code> types, for
6531 # example, perform type conversion across <code>==</code>, but not across
6532 # <code>eql?</code>, so:
6533 # 
6534 #    1 == 1.0     #=> true
6535 #    1.eql? 1.0   #=> false
6536 def eql?; true || false; end
6537 ##
6538 # Equality --- At the <code>Object</code> level, <code>==</code> returns
6539 # <code>true</code> only if +obj+ and +other+ are the same object.
6540 # Typically, this method is overridden in descendant classes to provide
6541 # class-specific meaning.
6542 # 
6543 # Unlike <code>==</code>, the <code>equal?</code> method should never be
6544 # overridden by subclasses as it is used to determine object identity
6545 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
6546 # same object as <code>b</code>):
6547 # 
6548 #   obj = "a"
6549 #   other = obj.dup
6550 # 
6551 #   a == other      #=> true
6552 #   a.equal? other  #=> false
6553 #   a.equal? a      #=> true
6554 # 
6555 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
6556 # +other+ refer to the same hash key.  This is used by Hash to test members
6557 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
6558 # is synonymous with <code>==</code>.  Subclasses normally continue this
6559 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
6560 # method, but there are exceptions.  <code>Numeric</code> types, for
6561 # example, perform type conversion across <code>==</code>, but not across
6562 # <code>eql?</code>, so:
6563 # 
6564 #    1 == 1.0     #=> true
6565 #    1.eql? 1.0   #=> false
6566 def equal?(other); true || false; end
6567 ##
6568 # Returns 0 if obj === other, otherwise nil.
6569 # 
6570 # The <=> is used by various methods to compare objects, for example
6571 # Enumerable#sort, Enumerable#max etc.
6572 # 
6573 # Your implementation of <=> should return one of the following values: -1, 0,
6574 # 1 or nil. -1 means self is smaller than other. 0 means self is equal to other.
6575 # 1 means self is bigger than other. Nil means the two values could not be
6576 # compared.
6577 # 
6578 # When you defined <=>, you can include Comparable to gain the methods <=, <,
6579 # ==, >=, > and between?.
6580 def <=>; 0 || nil; end
6581 ##
6582 # Returns the class of <i>obj</i>. This method must always be
6583 # called with an explicit receiver, as <code>class</code> is also a
6584 # reserved word in Ruby.
6585 # 
6586 #    1.class      #=> Fixnum
6587 #    self.class   #=> Object
6588 def class; Class.new; end
6589 ##
6590 # Returns the singleton class of <i>obj</i>.  This method creates
6591 # a new singleton class if <i>obj</i> does not have it.
6592 # 
6593 # If <i>obj</i> is <code>nil</code>, <code>true</code>, or
6594 # <code>false</code>, it returns NilClass, TrueClass, or FalseClass,
6595 # respectively.
6596 # If <i>obj</i> is a Fixnum or a Symbol, it raises a TypeError.
6597 # 
6598 #    Object.new.singleton_class  #=> #<Class:#<Object:0xb7ce1e24>>
6599 #    String.singleton_class      #=> #<Class:String>
6600 #    nil.singleton_class         #=> NilClass
6601 def singleton_class; Class.new; end
6602 ##
6603 # Produces a shallow copy of <i>obj</i>---the instance variables of
6604 # <i>obj</i> are copied, but not the objects they reference. Copies
6605 # the frozen and tainted state of <i>obj</i>. See also the discussion
6606 # under <code>Object#dup</code>.
6607 # 
6608 #    class Klass
6609 #       attr_accessor :str
6610 #    end
6611 #    s1 = Klass.new      #=> #<Klass:0x401b3a38>
6612 #    s1.str = "Hello"    #=> "Hello"
6613 #    s2 = s1.clone       #=> #<Klass:0x401b3998 @str="Hello">
6614 #    s2.str[1,4] = "i"   #=> "i"
6615 #    s1.inspect          #=> "#<Klass:0x401b3a38 @str=\"Hi\">"
6616 #    s2.inspect          #=> "#<Klass:0x401b3998 @str=\"Hi\">"
6617 # 
6618 # This method may have class-specific behavior.  If so, that
6619 # behavior will be documented under the #+initialize_copy+ method of
6620 # the class.
6621 def clone; Object.new; end
6622 ##
6623 # Produces a shallow copy of <i>obj</i>---the instance variables of
6624 # <i>obj</i> are copied, but not the objects they reference.
6625 # <code>dup</code> copies the tainted state of <i>obj</i>. See also
6626 # the discussion under <code>Object#clone</code>. In general,
6627 # <code>clone</code> and <code>dup</code> may have different semantics
6628 # in descendant classes. While <code>clone</code> is used to duplicate
6629 # an object, including its internal state, <code>dup</code> typically
6630 # uses the class of the descendant object to create the new instance.
6631 # 
6632 # This method may have class-specific behavior.  If so, that
6633 # behavior will be documented under the #+initialize_copy+ method of
6634 # the class.
6635 def dup; Object.new; end
6636 ##
6637 # Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is
6638 # set appropriately, many method calls which might alter the running
6639 # programs environment will refuse to accept tainted strings.
6640 def taint; Object.new; end
6641 ##
6642 # Returns <code>true</code> if the object is tainted.
6643 def tainted?; true || false; end
6644 ##
6645 # Removes the taint from <i>obj</i>.
6646 def untaint; Object.new; end
6647 ##
6648 # Marks <i>obj</i> as untrusted.
6649 def untrust; Object.new; end
6650 ##
6651 # Returns <code>true</code> if the object is untrusted.
6652 def untrusted?; true || false; end
6653 ##
6654 # Removes the untrusted mark from <i>obj</i>.
6655 def trust; Object.new; end
6656 ##
6657 # Prevents further modifications to <i>obj</i>. A
6658 # <code>RuntimeError</code> will be raised if modification is attempted.
6659 # There is no way to unfreeze a frozen object. See also
6660 # <code>Object#frozen?</code>.
6661 # 
6662 # This method returns self.
6663 # 
6664 #    a = [ "a", "b", "c" ]
6665 #    a.freeze
6666 #    a << "z"
6667 # 
6668 # <em>produces:</em>
6669 # 
6670 #    prog.rb:3:in `<<': can't modify frozen array (RuntimeError)
6671 #     from prog.rb:3
6672 def freeze; Object.new; end
6673 ##
6674 # Returns the freeze status of <i>obj</i>.
6675 # 
6676 #    a = [ "a", "b", "c" ]
6677 #    a.freeze    #=> ["a", "b", "c"]
6678 #    a.frozen?   #=> true
6679 def frozen?; true || false; end
6680 ##
6681 # Returns a string representing <i>obj</i>. The default
6682 # <code>to_s</code> prints the object's class and an encoding of the
6683 # object id. As a special case, the top-level object that is the
6684 # initial execution context of Ruby programs returns ``main.''
6685 def to_s; ''; end
6686 ##
6687 # Returns a string containing a human-readable representation of <i>obj</i>.
6688 # By default, show the class name and the list of the instance variables and
6689 # their values (by calling #inspect on each of them).
6690 # User defined classes should override this method to make better
6691 # representation of <i>obj</i>.  When overriding this method, it should
6692 # return a string whose encoding is compatible with the default external
6693 # encoding.
6694 # 
6695 #     [ 1, 2, 3..4, 'five' ].inspect   #=> "[1, 2, 3..4, \"five\"]"
6696 #     Time.new.inspect                 #=> "2008-03-08 19:43:39 +0900"
6697 # 
6698 #     class Foo
6699 #     end
6700 #     Foo.new.inspect                  #=> "#<Foo:0x0300c868>"
6701 # 
6702 #     class Bar
6703 #       def initialize
6704 #         @bar = 1
6705 #       end
6706 #     end
6707 #     Bar.new.inspect                  #=> "#<Bar:0x0300c868 @bar=1>"
6708 # 
6709 #     class Baz
6710 #       def to_s
6711 #         "baz"
6712 #       end
6713 #     end
6714 #     Baz.new.inspect                  #=> "#<Baz:0x0300c868>"
6715 def inspect; ''; end
6716 ##
6717 # Returns a list of the names of public and protected methods of
6718 # <i>obj</i>. This will include all the methods accessible in
6719 # <i>obj</i>'s ancestors.
6720 # If the <i>all</i> parameter is set to <code>false</code>, only those methods
6721 # in the receiver will be listed.
6722 # 
6723 #    class Klass
6724 #      def klass_method()
6725 #      end
6726 #    end
6727 #    k = Klass.new
6728 #    k.methods[0..9]    #=> [:klass_method, :nil?, :===,
6729 #                       #    :==~, :!, :eql?
6730 #                       #    :hash, :<=>, :class, :singleton_class]
6731 #    k.methods.length   #=> 57
6732 def methods(all=true); []; end
6733 ##
6734 # Returns an array of the names of singleton methods for <i>obj</i>.
6735 # If the optional <i>all</i> parameter is true, the list will include
6736 # methods in modules included in <i>obj</i>.
6737 # Only public and protected singleton methods are returned.
6738 # 
6739 #    module Other
6740 #      def three() end
6741 #    end
6742 # 
6743 #    class Single
6744 #      def Single.four() end
6745 #    end
6746 # 
6747 #    a = Single.new
6748 # 
6749 #    def a.one()
6750 #    end
6751 # 
6752 #    class << a
6753 #      include Other
6754 #      def two()
6755 #      end
6756 #    end
6757 # 
6758 #    Single.singleton_methods    #=> [:four]
6759 #    a.singleton_methods(false)  #=> [:two, :one]
6760 #    a.singleton_methods         #=> [:two, :one, :three]
6761 def singleton_methods(all=true); []; end
6762 ##
6763 # Returns the list of protected methods accessible to <i>obj</i>. If
6764 # the <i>all</i> parameter is set to <code>false</code>, only those methods
6765 # in the receiver will be listed.
6766 def protected_methods(all=true); []; end
6767 ##
6768 # Returns the list of private methods accessible to <i>obj</i>. If
6769 # the <i>all</i> parameter is set to <code>false</code>, only those methods
6770 # in the receiver will be listed.
6771 def private_methods(all=true); []; end
6772 ##
6773 # Returns the list of public methods accessible to <i>obj</i>. If
6774 # the <i>all</i> parameter is set to <code>false</code>, only those methods
6775 # in the receiver will be listed.
6776 def public_methods(all=true); []; end
6777 ##
6778 # Returns an array of instance variable names for the receiver. Note
6779 # that simply defining an accessor does not create the corresponding
6780 # instance variable.
6781 # 
6782 #    class Fred
6783 #      attr_accessor :a1
6784 #      def initialize
6785 #        @iv = 3
6786 #      end
6787 #    end
6788 #    Fred.new.instance_variables   #=> [:@iv]
6789 def instance_variables; []; end
6790 ##
6791 # Returns the value of the given instance variable, or nil if the
6792 # instance variable is not set. The <code>@</code> part of the
6793 # variable name should be included for regular instance
6794 # variables. Throws a <code>NameError</code> exception if the
6795 # supplied symbol is not valid as an instance variable name.
6796 # String arguments are converted to symbols.
6797 # 
6798 #    class Fred
6799 #      def initialize(p1, p2)
6800 #        @a, @b = p1, p2
6801 #      end
6802 #    end
6803 #    fred = Fred.new('cat', 99)
6804 #    fred.instance_variable_get(:@a)    #=> "cat"
6805 #    fred.instance_variable_get("@b")   #=> 99
6806 def instance_variable_get(symbol); Object.new; end
6807 ##
6808 # Sets the instance variable names by <i>symbol</i> to
6809 # <i>object</i>, thereby frustrating the efforts of the class's
6810 # author to attempt to provide proper encapsulation. The variable
6811 # did not have to exist prior to this call.
6812 # If the instance variable name is passed as a string, that string
6813 # is converted to a symbol.
6814 # 
6815 #    class Fred
6816 #      def initialize(p1, p2)
6817 #        @a, @b = p1, p2
6818 #      end
6819 #    end
6820 #    fred = Fred.new('cat', 99)
6821 #    fred.instance_variable_set(:@a, 'dog')   #=> "dog"
6822 #    fred.instance_variable_set(:@c, 'cat')   #=> "cat"
6823 #    fred.inspect                             #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
6824 def instance_variable_set(symbol, obj); Object.new; end
6825 ##
6826 # Returns <code>true</code> if the given instance variable is
6827 # defined in <i>obj</i>.
6828 # String arguments are converted to symbols.
6829 # 
6830 #    class Fred
6831 #      def initialize(p1, p2)
6832 #        @a, @b = p1, p2
6833 #      end
6834 #    end
6835 #    fred = Fred.new('cat', 99)
6836 #    fred.instance_variable_defined?(:@a)    #=> true
6837 #    fred.instance_variable_defined?("@b")   #=> true
6838 #    fred.instance_variable_defined?("@c")   #=> false
6839 def instance_variable_defined?(symbol); true || false; end
6840 ##
6841 # Removes the named instance variable from <i>obj</i>, returning that
6842 # variable's value.
6843 # 
6844 #    class Dummy
6845 #      attr_reader :var
6846 #      def initialize
6847 #        @var = 99
6848 #      end
6849 #      def remove
6850 #        remove_instance_variable(:@var)
6851 #      end
6852 #    end
6853 #    d = Dummy.new
6854 #    d.var      #=> 99
6855 #    d.remove   #=> 99
6856 #    d.var      #=> nil
6857 def remove_instance_variable(symbol); Object.new; end
6858 ##
6859 # Returns <code>true</code> if <i>obj</i> is an instance of the given
6860 # class. See also <code>Object#kind_of?</code>.
6861 # 
6862 #    class A;     end
6863 #    class B < A; end
6864 #    class C < B; end
6865 # 
6866 #    b = B.new
6867 #    b.instance_of? A   #=> false
6868 #    b.instance_of? B   #=> true
6869 #    b.instance_of? C   #=> false
6870 def instance_of?(klass); true || false; end
6871 ##
6872 # Returns <code>true</code> if <i>class</i> is the class of
6873 # <i>obj</i>, or if <i>class</i> is one of the superclasses of
6874 # <i>obj</i> or modules included in <i>obj</i>.
6875 # 
6876 #    module M;    end
6877 #    class A
6878 #      include M
6879 #    end
6880 #    class B < A; end
6881 #    class C < B; end
6882 # 
6883 #    b = B.new
6884 #    b.is_a? A          #=> true
6885 #    b.is_a? B          #=> true
6886 #    b.is_a? C          #=> false
6887 #    b.is_a? M          #=> true
6888 # 
6889 #    b.kind_of? A       #=> true
6890 #    b.kind_of? B       #=> true
6891 #    b.kind_of? C       #=> false
6892 #    b.kind_of? M       #=> true
6893 def is_a?(klass); true || false; end
6894 ##
6895 # Returns <code>true</code> if <i>class</i> is the class of
6896 # <i>obj</i>, or if <i>class</i> is one of the superclasses of
6897 # <i>obj</i> or modules included in <i>obj</i>.
6898 # 
6899 #    module M;    end
6900 #    class A
6901 #      include M
6902 #    end
6903 #    class B < A; end
6904 #    class C < B; end
6905 # 
6906 #    b = B.new
6907 #    b.is_a? A          #=> true
6908 #    b.is_a? B          #=> true
6909 #    b.is_a? C          #=> false
6910 #    b.is_a? M          #=> true
6911 # 
6912 #    b.kind_of? A       #=> true
6913 #    b.kind_of? B       #=> true
6914 #    b.kind_of? C       #=> false
6915 #    b.kind_of? M       #=> true
6916 def kind_of?(klass); true || false; end
6917 ##
6918 # Yields <code>x</code> to the block, and then returns <code>x</code>.
6919 # The primary purpose of this method is to "tap into" a method chain,
6920 # in order to perform operations on intermediate results within the chain.
6921 # 
6922 #     (1..10)                .tap {|x| puts "original: #{x.inspect}"}
6923 #       .to_a                .tap {|x| puts "array: #{x.inspect}"}
6924 #       .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"}
6925 #       .map { |x| x*x }     .tap {|x| puts "squares: #{x.inspect}"}
6926 def tap(&block); Object.new; end
6927 ##
6928 # Creates a new Enumerator which will enumerate by calling +method+ on
6929 # +obj+, passing +args+ if any.
6930 # 
6931 # If a block is given, it will be used to calculate the size of
6932 # the enumerator without the need to iterate it (see Enumerator#size).
6933 # 
6934 # === Examples
6935 # 
6936 #   str = "xyz"
6937 # 
6938 #   enum = str.enum_for(:each_byte)
6939 #   enum.each { |b| puts b }
6940 #   # => 120
6941 #   # => 121
6942 #   # => 122
6943 # 
6944 #   # protect an array from being modified by some_method
6945 #   a = [1, 2, 3]
6946 #   some_method(a.to_enum)
6947 # 
6948 # It is typical to call to_enum when defining methods for
6949 # a generic Enumerable, in case no block is passed.
6950 # 
6951 # Here is such an example, with parameter passing and a sizing block:
6952 # 
6953 #   module Enumerable
6954 #     # a generic method to repeat the values of any enumerable
6955 #     def repeat(n)
6956 #       raise ArgumentError, "#{n} is negative!" if n < 0
6957 #       unless block_given?
6958 #         return to_enum(__method__, n) do # __method__ is :repeat here
6959 #           sz = size     # Call size and multiply by n...
6960 #           sz * n if sz  # but return nil if size itself is nil
6961 #         end
6962 #       end
6963 #       each do |*val|
6964 #         n.times { yield *val }
6965 #       end
6966 #     end
6967 #   end
6968 # 
6969 #   %i[hello world].repeat(2) { |w| puts w }
6970 #     # => Prints 'hello', 'hello', 'world', 'world'
6971 #   enum = (1..14).repeat(3)
6972 #     # => returns an Enumerator when called without a block
6973 #   enum.first(4) # => [1, 1, 1, 2]
6974 #   enum.size # => 42
6975 def to_enum(); Enumerator.new; end
6976 ##
6977 # Creates a new Enumerator which will enumerate by calling +method+ on
6978 # +obj+, passing +args+ if any.
6979 # 
6980 # If a block is given, it will be used to calculate the size of
6981 # the enumerator without the need to iterate it (see Enumerator#size).
6982 # 
6983 # === Examples
6984 # 
6985 #   str = "xyz"
6986 # 
6987 #   enum = str.enum_for(:each_byte)
6988 #   enum.each { |b| puts b }
6989 #   # => 120
6990 #   # => 121
6991 #   # => 122
6992 # 
6993 #   # protect an array from being modified by some_method
6994 #   a = [1, 2, 3]
6995 #   some_method(a.to_enum)
6996 # 
6997 # It is typical to call to_enum when defining methods for
6998 # a generic Enumerable, in case no block is passed.
6999 # 
7000 # Here is such an example, with parameter passing and a sizing block:
7001 # 
7002 #   module Enumerable
7003 #     # a generic method to repeat the values of any enumerable
7004 #     def repeat(n)
7005 #       raise ArgumentError, "#{n} is negative!" if n < 0
7006 #       unless block_given?
7007 #         return to_enum(__method__, n) do # __method__ is :repeat here
7008 #           sz = size     # Call size and multiply by n...
7009 #           sz * n if sz  # but return nil if size itself is nil
7010 #         end
7011 #       end
7012 #       each do |*val|
7013 #         n.times { yield *val }
7014 #       end
7015 #     end
7016 #   end
7017 # 
7018 #   %i[hello world].repeat(2) { |w| puts w }
7019 #     # => Prints 'hello', 'hello', 'world', 'world'
7020 #   enum = (1..14).repeat(3)
7021 #     # => returns an Enumerator when called without a block
7022 #   enum.first(4) # => [1, 1, 1, 2]
7023 #   enum.size # => 42
7024 def enum_for(); Enumerator.new; end
7025 ##
7026 # Prints <i>obj</i> on the given port (default <code>$></code>).
7027 # Equivalent to:
7028 # 
7029 #    def display(port=$>)
7030 #      port.write self
7031 #    end
7032 # 
7033 # For example:
7034 # 
7035 #    1.display
7036 #    "cat".display
7037 #    [ 4, 5, 6 ].display
7038 #    puts
7039 # 
7040 # <em>produces:</em>
7041 # 
7042 #    1cat456
7043 def display(port=$>); end
7044 end
7045 
7046 ##
7047 # A <code>String</code> object holds and manipulates an arbitrary sequence of
7048 # bytes, typically representing characters. String objects may be created
7049 # using <code>String::new</code> or as literals.
7050 # 
7051 # Because of aliasing issues, users of strings should be aware of the methods
7052 # that modify the contents of a <code>String</code> object.  Typically,
7053 # methods with names ending in ``!'' modify their receiver, while those
7054 # without a ``!'' return a new <code>String</code>.  However, there are
7055 # exceptions, such as <code>String#[]=</code>.
7056 class String < Object
7057 include Comparable
7058 ##
7059 # Try to convert <i>obj</i> into a String, using to_str method.
7060 # Returns converted string or nil if <i>obj</i> cannot be converted
7061 # for any reason.
7062 # 
7063 #    String.try_convert("str")     #=> "str"
7064 #    String.try_convert(/re/)      #=> nil
7065 def self.try_convert(obj); '' || nil; end
7066 ##
7067 # Returns a new string object containing a copy of <i>str</i>.
7068 def self.new(str=""); end
7069 ##
7070 # Replaces the contents and taintedness of <i>str</i> with the corresponding
7071 # values in <i>other_str</i>.
7072 # 
7073 #    s = "hello"         #=> "hello"
7074 #    s.replace "world"   #=> "world"
7075 def replace(other_str); ''; end
7076 ##
7077 # Comparison---Returns -1, 0, +1 or nil depending on whether +string+ is less
7078 # than, equal to, or greater than +other_string+.
7079 # 
7080 # +nil+ is returned if the two values are incomparable.
7081 # 
7082 # If the strings are of different lengths, and the strings are equal when
7083 # compared up to the shortest length, then the longer string is considered
7084 # greater than the shorter one.
7085 # 
7086 # <code><=></code> is the basis for the methods <code><</code>,
7087 # <code><=</code>, <code>></code>, <code>>=</code>, and
7088 # <code>between?</code>, included from module Comparable. The method
7089 # String#== does not use Comparable#==.
7090 # 
7091 #    "abcdef" <=> "abcde"     #=> 1
7092 #    "abcdef" <=> "abcdef"    #=> 0
7093 #    "abcdef" <=> "abcdefg"   #=> -1
7094 #    "abcdef" <=> "ABCDEF"    #=> 1
7095 def <=>; 1 || nil; end
7096 ##
7097 # Equality---If <i>obj</i> is not a <code>String</code>, returns
7098 # <code>false</code>. Otherwise, returns <code>true</code> if <i>str</i>
7099 # <code><=></code> <i>obj</i> returns zero.
7100 def ==; true || false; end
7101 ##
7102 # Equality---If <i>obj</i> is not a <code>String</code>, returns
7103 # <code>false</code>. Otherwise, returns <code>true</code> if <i>str</i>
7104 # <code><=></code> <i>obj</i> returns zero.
7105 def ===; true || false; end
7106 ##
7107 # Two strings are equal if they have the same length and content.
7108 def eql?(other); true || false; end
7109 ##
7110 # Return a hash based on the string's length and content.
7111 def hash; 0; end
7112 ##
7113 # Case-insensitive version of <code>String#<=></code>.
7114 # 
7115 #    "abcdef".casecmp("abcde")     #=> 1
7116 #    "aBcDeF".casecmp("abcdef")    #=> 0
7117 #    "abcdef".casecmp("abcdefg")   #=> -1
7118 #    "abcdef".casecmp("ABCDEF")    #=> 0
7119 def casecmp(other_str); 1 || nil; end
7120 ##
7121 # Concatenation---Returns a new <code>String</code> containing
7122 # <i>other_str</i> concatenated to <i>str</i>.
7123 # 
7124 #    "Hello from " + self.to_s   #=> "Hello from main"
7125 def +; ''; end
7126 ##
7127 # Copy --- Returns a new String containing +integer+ copies of the receiver.
7128 # +integer+ must be greater than or equal to 0.
7129 # 
7130 #    "Ho! " * 3   #=> "Ho! Ho! Ho! "
7131 #    "Ho! " * 0   #=> ""
7132 def *; ''; end
7133 ##
7134 # Format---Uses <i>str</i> as a format specification, and returns the result
7135 # of applying it to <i>arg</i>. If the format specification contains more than
7136 # one substitution, then <i>arg</i> must be an <code>Array</code> or <code>Hash</code>
7137 # containing the values to be substituted. See <code>Kernel::sprintf</code> for
7138 # details of the format string.
7139 # 
7140 #    "%05d" % 123                              #=> "00123"
7141 #    "%-5s: %08x" % [ "ID", self.object_id ]   #=> "ID   : 200e14d6"
7142 #    "foo = %{foo}" % { :foo => 'bar' }        #=> "foo = bar"
7143 def %; ''; end
7144 ##
7145 # Element Reference --- If passed a single +index+, returns a substring of
7146 # one character at that index. If passed a +start+ index and a +length+,
7147 # returns a substring containing +length+ characters starting at the
7148 # +index+. If passed a +range+, its beginning and end are interpreted as
7149 # offsets delimiting the substring to be returned.
7150 # 
7151 # In these three cases, if an index is negative, it is counted from the end
7152 # of the string.  For the +start+ and +range+ cases the starting index
7153 # is just before a character and an index matching the string's size.
7154 # Additionally, an empty string is returned when the starting index for a
7155 # character range is at the end of the string.
7156 # 
7157 # Returns +nil+ if the initial index falls outside the string or the length
7158 # is negative.
7159 # 
7160 # If a +Regexp+ is supplied, the matching portion of the string is
7161 # returned.  If a +capture+ follows the regular expression, which may be a
7162 # capture group index or name, follows the regular expression that component
7163 # of the MatchData is returned instead.
7164 # 
7165 # If a +match_str+ is given, that string is returned if it occurs in
7166 # the string.
7167 # 
7168 # Returns +nil+ if the regular expression does not match or the match string
7169 # cannot be found.
7170 # 
7171 #    a = "hello there"
7172 # 
7173 #    a[1]                   #=> "e"
7174 #    a[2, 3]                #=> "llo"
7175 #    a[2..3]                #=> "ll"
7176 # 
7177 #    a[-3, 2]               #=> "er"
7178 #    a[7..-2]               #=> "her"
7179 #    a[-4..-2]              #=> "her"
7180 #    a[-2..-4]              #=> ""
7181 # 
7182 #    a[11, 0]               #=> ""
7183 #    a[11]                  #=> nil
7184 #    a[12, 0]               #=> nil
7185 #    a[12..-1]              #=> nil
7186 # 
7187 #    a[/[aeiou](.)\1/]      #=> "ell"
7188 #    a[/[aeiou](.)\1/, 0]   #=> "ell"
7189 #    a[/[aeiou](.)\1/, 1]   #=> "l"
7190 #    a[/[aeiou](.)\1/, 2]   #=> nil
7191 # 
7192 #    a[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, "non_vowel"] #=> "l"
7193 #    a[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, "vowel"]     #=> "e"
7194 # 
7195 #    a["lo"]                #=> "lo"
7196 #    a["bye"]               #=> nil
7197 def []; '' || nil; end
7198 ##
7199 # Element Reference --- If passed a single +index+, returns a substring of
7200 # one character at that index. If passed a +start+ index and a +length+,
7201 # returns a substring containing +length+ characters starting at the
7202 # +index+. If passed a +range+, its beginning and end are interpreted as
7203 # offsets delimiting the substring to be returned.
7204 # 
7205 # In these three cases, if an index is negative, it is counted from the end
7206 # of the string.  For the +start+ and +range+ cases the starting index
7207 # is just before a character and an index matching the string's size.
7208 # Additionally, an empty string is returned when the starting index for a
7209 # character range is at the end of the string.
7210 # 
7211 # Returns +nil+ if the initial index falls outside the string or the length
7212 # is negative.
7213 # 
7214 # If a +Regexp+ is supplied, the matching portion of the string is
7215 # returned.  If a +capture+ follows the regular expression, which may be a
7216 # capture group index or name, follows the regular expression that component
7217 # of the MatchData is returned instead.
7218 # 
7219 # If a +match_str+ is given, that string is returned if it occurs in
7220 # the string.
7221 # 
7222 # Returns +nil+ if the regular expression does not match or the match string
7223 # cannot be found.
7224 # 
7225 #    a = "hello there"
7226 # 
7227 #    a[1]                   #=> "e"
7228 #    a[2, 3]                #=> "llo"
7229 #    a[2..3]                #=> "ll"
7230 # 
7231 #    a[-3, 2]               #=> "er"
7232 #    a[7..-2]               #=> "her"
7233 #    a[-4..-2]              #=> "her"
7234 #    a[-2..-4]              #=> ""
7235 # 
7236 #    a[11, 0]               #=> ""
7237 #    a[11]                  #=> nil
7238 #    a[12, 0]               #=> nil
7239 #    a[12..-1]              #=> nil
7240 # 
7241 #    a[/[aeiou](.)\1/]      #=> "ell"
7242 #    a[/[aeiou](.)\1/, 0]   #=> "ell"
7243 #    a[/[aeiou](.)\1/, 1]   #=> "l"
7244 #    a[/[aeiou](.)\1/, 2]   #=> nil
7245 # 
7246 #    a[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, "non_vowel"] #=> "l"
7247 #    a[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, "vowel"]     #=> "e"
7248 # 
7249 #    a["lo"]                #=> "lo"
7250 #    a["bye"]               #=> nil
7251 def slice(index); '' || nil; end
7252 ##
7253 # Element Assignment---Replaces some or all of the content of <i>str</i>. The
7254 # portion of the string affected is determined using the same criteria as
7255 # <code>String#[]</code>. If the replacement string is not the same length as
7256 # the text it is replacing, the string will be adjusted accordingly. If the
7257 # regular expression or string is used as the index doesn't match a position
7258 # in the string, <code>IndexError</code> is raised. If the regular expression
7259 # form is used, the optional second <code>Fixnum</code> allows you to specify
7260 # which portion of the match to replace (effectively using the
7261 # <code>MatchData</code> indexing rules. The forms that take a
7262 # <code>Fixnum</code> will raise an <code>IndexError</code> if the value is
7263 # out of range; the <code>Range</code> form will raise a
7264 # <code>RangeError</code>, and the <code>Regexp</code> and <code>String</code>
7265 # will raise an <code>IndexError</code> on negative match.
7266 def []=; end
7267 ##
7268 # Inserts <i>other_str</i> before the character at the given
7269 # <i>index</i>, modifying <i>str</i>. Negative indices count from the
7270 # end of the string, and insert <em>after</em> the given character.
7271 # The intent is insert <i>aString</i> so that it starts at the given
7272 # <i>index</i>.
7273 # 
7274 #    "abcd".insert(0, 'X')    #=> "Xabcd"
7275 #    "abcd".insert(3, 'X')    #=> "abcXd"
7276 #    "abcd".insert(4, 'X')    #=> "abcdX"
7277 #    "abcd".insert(-3, 'X')   #=> "abXcd"
7278 #    "abcd".insert(-1, 'X')   #=> "abcdX"
7279 def insert(index, other_str); ''; end
7280 ##
7281 # Returns the character length of <i>str</i>.
7282 def length; 0; end
7283 ##
7284 # Returns the character length of <i>str</i>.
7285 def size; 0; end
7286 ##
7287 # Returns the length of +str+ in bytes.
7288 # 
7289 #   "\x80\u3042".bytesize  #=> 4
7290 #   "hello".bytesize       #=> 5
7291 def bytesize; 0; end
7292 ##
7293 # Returns <code>true</code> if <i>str</i> has a length of zero.
7294 # 
7295 #    "hello".empty?   #=> false
7296 #    " ".empty?       #=> false
7297 #    "".empty?        #=> true
7298 def empty?; true || false; end
7299 ##
7300 # Match---If <i>obj</i> is a <code>Regexp</code>, use it as a pattern to match
7301 # against <i>str</i>,and returns the position the match starts, or
7302 # <code>nil</code> if there is no match. Otherwise, invokes
7303 # <i>obj.=~</i>, passing <i>str</i> as an argument. The default
7304 # <code>=~</code> in <code>Object</code> returns <code>nil</code>.
7305 # 
7306 # Note: <code>str =~ regexp</code> is not the same as
7307 # <code>regexp =~ str</code>. Strings captured from named capture groups
7308 # are assigned to local variables only in the second case.
7309 # 
7310 #    "cat o' 9 tails" =~ /\d/   #=> 7
7311 #    "cat o' 9 tails" =~ 9      #=> nil
7312 def =~; 1 || nil; end
7313 ##
7314 # Converts <i>pattern</i> to a <code>Regexp</code> (if it isn't already one),
7315 # then invokes its <code>match</code> method on <i>str</i>.  If the second
7316 # parameter is present, it specifies the position in the string to begin the
7317 # search.
7318 # 
7319 #    'hello'.match('(.)\1')      #=> #<MatchData "ll" 1:"l">
7320 #    'hello'.match('(.)\1')[0]   #=> "ll"
7321 #    'hello'.match(/(.)\1/)[0]   #=> "ll"
7322 #    'hello'.match('xx')         #=> nil
7323 # 
7324 # If a block is given, invoke the block with MatchData if match succeed, so
7325 # that you can write
7326 # 
7327 #    str.match(pat) {|m| ...}
7328 # 
7329 # instead of
7330 # 
7331 #    if m = str.match(pat)
7332 #      ...
7333 #    end
7334 # 
7335 # The return value is a value from block execution in this case.
7336 def match(pattern); MatchData.new || nil; end
7337 ##
7338 # Returns the successor to <i>str</i>. The successor is calculated by
7339 # incrementing characters starting from the rightmost alphanumeric (or
7340 # the rightmost character if there are no alphanumerics) in the
7341 # string. Incrementing a digit always results in another digit, and
7342 # incrementing a letter results in another letter of the same case.
7343 # Incrementing nonalphanumerics uses the underlying character set's
7344 # collating sequence.
7345 # 
7346 # If the increment generates a ``carry,'' the character to the left of
7347 # it is incremented. This process repeats until there is no carry,
7348 # adding an additional character if necessary.
7349 # 
7350 #    "abcd".succ        #=> "abce"
7351 #    "THX1138".succ     #=> "THX1139"
7352 #    "<<koala>>".succ   #=> "<<koalb>>"
7353 #    "1999zzz".succ     #=> "2000aaa"
7354 #    "ZZZ9999".succ     #=> "AAAA0000"
7355 #    "***".succ         #=> "**+"
7356 def succ; ''; end
7357 ##
7358 # Returns the successor to <i>str</i>. The successor is calculated by
7359 # incrementing characters starting from the rightmost alphanumeric (or
7360 # the rightmost character if there are no alphanumerics) in the
7361 # string. Incrementing a digit always results in another digit, and
7362 # incrementing a letter results in another letter of the same case.
7363 # Incrementing nonalphanumerics uses the underlying character set's
7364 # collating sequence.
7365 # 
7366 # If the increment generates a ``carry,'' the character to the left of
7367 # it is incremented. This process repeats until there is no carry,
7368 # adding an additional character if necessary.
7369 # 
7370 #    "abcd".succ        #=> "abce"
7371 #    "THX1138".succ     #=> "THX1139"
7372 #    "<<koala>>".succ   #=> "<<koalb>>"
7373 #    "1999zzz".succ     #=> "2000aaa"
7374 #    "ZZZ9999".succ     #=> "AAAA0000"
7375 #    "***".succ         #=> "**+"
7376 def next; ''; end
7377 ##
7378 # Equivalent to <code>String#succ</code>, but modifies the receiver in
7379 # place.
7380 def succ!; ''; end
7381 ##
7382 # Equivalent to <code>String#succ</code>, but modifies the receiver in
7383 # place.
7384 def next!; ''; end
7385 ##
7386 # Iterates through successive values, starting at <i>str</i> and
7387 # ending at <i>other_str</i> inclusive, passing each value in turn to
7388 # the block. The <code>String#succ</code> method is used to generate
7389 # each value.  If optional second argument exclusive is omitted or is false,
7390 # the last value will be included; otherwise it will be excluded.
7391 # 
7392 # If no block is given, an enumerator is returned instead.
7393 # 
7394 #    "a8".upto("b6") {|s| print s, ' ' }
7395 #    for s in "a8".."b6"
7396 #      print s, ' '
7397 #    end
7398 # 
7399 # <em>produces:</em>
7400 # 
7401 #    a8 a9 b0 b1 b2 b3 b4 b5 b6
7402 #    a8 a9 b0 b1 b2 b3 b4 b5 b6
7403 # 
7404 # If <i>str</i> and <i>other_str</i> contains only ascii numeric characters,
7405 # both are recognized as decimal numbers. In addition, the width of
7406 # string (e.g. leading zeros) is handled appropriately.
7407 # 
7408 #    "9".upto("11").to_a   #=> ["9", "10", "11"]
7409 #    "25".upto("5").to_a   #=> []
7410 #    "07".upto("11").to_a  #=> ["07", "08", "09", "10", "11"]
7411 def upto(other_str, exclusive=false, &block); Enumerator.new; end
7412 ##
7413 # Returns the index of the first occurrence of the given <i>substring</i> or
7414 # pattern (<i>regexp</i>) in <i>str</i>. Returns <code>nil</code> if not
7415 # found. If the second parameter is present, it specifies the position in the
7416 # string to begin the search.
7417 # 
7418 #    "hello".index('e')             #=> 1
7419 #    "hello".index('lo')            #=> 3
7420 #    "hello".index('a')             #=> nil
7421 #    "hello".index(?e)              #=> 1
7422 #    "hello".index(/[aeiou]/, -3)   #=> 4
7423 def index(substring , offset=0); 1 || nil; end
7424 ##
7425 # Returns the index of the last occurrence of the given <i>substring</i> or
7426 # pattern (<i>regexp</i>) in <i>str</i>. Returns <code>nil</code> if not
7427 # found. If the second parameter is present, it specifies the position in the
7428 # string to end the search---characters beyond this point will not be
7429 # considered.
7430 # 
7431 #    "hello".rindex('e')             #=> 1
7432 #    "hello".rindex('l')             #=> 3
7433 #    "hello".rindex('a')             #=> nil
7434 #    "hello".rindex(?e)              #=> 1
7435 #    "hello".rindex(/[aeiou]/, -2)   #=> 1
7436 def rindex(substring , fixnum=0); 1 || nil; end
7437 ##
7438 # Makes string empty.
7439 # 
7440 #    a = "abcde"
7441 #    a.clear    #=> ""
7442 def clear; ''; end
7443 ##
7444 # Returns a one-character string at the beginning of the string.
7445 # 
7446 #    a = "abcde"
7447 #    a.chr    #=> "a"
7448 def chr; ''; end
7449 ##
7450 # returns the <i>index</i>th byte as an integer.
7451 def getbyte(index); 0..255; end
7452 ##
7453 # modifies the <i>index</i>th byte as <i>int</i>.
7454 def setbyte(index, int); 0; end
7455 ##
7456 # Byte Reference---If passed a single <code>Fixnum</code>, returns a
7457 # substring of one byte at that position. If passed two <code>Fixnum</code>
7458 # objects, returns a substring starting at the offset given by the first, and
7459 # a length given by the second. If given a <code>Range</code>, a substring containing
7460 # bytes at offsets given by the range is returned. In all three cases, if
7461 # an offset is negative, it is counted from the end of <i>str</i>. Returns
7462 # <code>nil</code> if the initial offset falls outside the string, the length
7463 # is negative, or the beginning of the range is greater than the end.
7464 # The encoding of the resulted string keeps original encoding.
7465 # 
7466 #    "hello".byteslice(1)     #=> "e"
7467 #    "hello".byteslice(-1)    #=> "o"
7468 #    "hello".byteslice(1, 2)  #=> "el"
7469 #    "\x80\u3042".byteslice(1, 3) #=> "\u3042"
7470 #    "\x03\u3042\xff".byteslice(1..3) #=> "\u3042"
7471 def byteslice(fixnum); '' || nil; end
7472 ##
7473 # Returns the result of interpreting leading characters in <i>str</i> as an
7474 # integer base <i>base</i> (between 2 and 36). Extraneous characters past the
7475 # end of a valid number are ignored. If there is not a valid number at the
7476 # start of <i>str</i>, <code>0</code> is returned. This method never raises an
7477 # exception when <i>base</i> is valid.
7478 # 
7479 #    "12345".to_i             #=> 12345
7480 #    "99 red balloons".to_i   #=> 99
7481 #    "0a".to_i                #=> 0
7482 #    "0a".to_i(16)            #=> 10
7483 #    "hello".to_i             #=> 0
7484 #    "1100101".to_i(2)        #=> 101
7485 #    "1100101".to_i(8)        #=> 294977
7486 #    "1100101".to_i(10)       #=> 1100101
7487 #    "1100101".to_i(16)       #=> 17826049
7488 def to_i(base=10); 0; end
7489 ##
7490 # Returns the result of interpreting leading characters in <i>str</i> as a
7491 # floating point number. Extraneous characters past the end of a valid number
7492 # are ignored. If there is not a valid number at the start of <i>str</i>,
7493 # <code>0.0</code> is returned. This method never raises an exception.
7494 # 
7495 #    "123.45e1".to_f        #=> 1234.5
7496 #    "45.67 degrees".to_f   #=> 45.67
7497 #    "thx1138".to_f         #=> 0.0
7498 def to_f; 0.0; end
7499 ##
7500 # Returns the receiver.
7501 def to_s; ''; end
7502 ##
7503 # Returns the receiver.
7504 def to_str; ''; end
7505 ##
7506 # Returns a printable version of _str_, surrounded by quote marks,
7507 # with special characters escaped.
7508 # 
7509 #    str = "hello"
7510 #    str[3] = "\b"
7511 #    str.inspect       #=> "\"hel\\bo\""
7512 def inspect; ''; end
7513 ##
7514 # Produces a version of +str+ with all non-printing characters replaced by
7515 # <code>\nnn</code> notation and all special characters escaped.
7516 # 
7517 #   "hello \n ''".dump  #=> "\"hello \\n ''\"
7518 def dump; ''; end
7519 ##
7520 # Returns a copy of <i>str</i> with all lowercase letters replaced with their
7521 # uppercase counterparts. The operation is locale insensitive---only
7522 # characters ``a'' to ``z'' are affected.
7523 # Note: case replacement is effective only in ASCII region.
7524 # 
7525 #    "hEllO".upcase   #=> "HELLO"
7526 def upcase; ''; end
7527 ##
7528 # Returns a copy of <i>str</i> with all uppercase letters replaced with their
7529 # lowercase counterparts. The operation is locale insensitive---only
7530 # characters ``A'' to ``Z'' are affected.
7531 # Note: case replacement is effective only in ASCII region.
7532 # 
7533 #    "hEllO".downcase   #=> "hello"
7534 def downcase; ''; end
7535 ##
7536 # Returns a copy of <i>str</i> with the first character converted to uppercase
7537 # and the remainder to lowercase.
7538 # Note: case conversion is effective only in ASCII region.
7539 # 
7540 #    "hello".capitalize    #=> "Hello"
7541 #    "HELLO".capitalize    #=> "Hello"
7542 #    "123ABC".capitalize   #=> "123abc"
7543 def capitalize; ''; end
7544 ##
7545 # Returns a copy of <i>str</i> with uppercase alphabetic characters converted
7546 # to lowercase and lowercase characters converted to uppercase.
7547 # Note: case conversion is effective only in ASCII region.
7548 # 
7549 #    "Hello".swapcase          #=> "hELLO"
7550 #    "cYbEr_PuNk11".swapcase   #=> "CyBeR_pUnK11"
7551 def swapcase; ''; end
7552 ##
7553 # Upcases the contents of <i>str</i>, returning <code>nil</code> if no changes
7554 # were made.
7555 # Note: case replacement is effective only in ASCII region.
7556 def upcase!; '' || nil; end
7557 ##
7558 # Downcases the contents of <i>str</i>, returning <code>nil</code> if no
7559 # changes were made.
7560 # Note: case replacement is effective only in ASCII region.
7561 def downcase!; '' || nil; end
7562 ##
7563 # Modifies <i>str</i> by converting the first character to uppercase and the
7564 # remainder to lowercase. Returns <code>nil</code> if no changes are made.
7565 # Note: case conversion is effective only in ASCII region.
7566 # 
7567 #    a = "hello"
7568 #    a.capitalize!   #=> "Hello"
7569 #    a               #=> "Hello"
7570 #    a.capitalize!   #=> nil
7571 def capitalize!; '' || nil; end
7572 ##
7573 # Equivalent to <code>String#swapcase</code>, but modifies the receiver in
7574 # place, returning <i>str</i>, or <code>nil</code> if no changes were made.
7575 # Note: case conversion is effective only in ASCII region.
7576 def swapcase!; '' || nil; end
7577 ##
7578 # Treats leading characters from <i>str</i> as a string of hexadecimal digits
7579 # (with an optional sign and an optional <code>0x</code>) and returns the
7580 # corresponding number. Zero is returned on error.
7581 # 
7582 #    "0x0a".hex     #=> 10
7583 #    "-1234".hex    #=> -4660
7584 #    "0".hex        #=> 0
7585 #    "wombat".hex   #=> 0
7586 def hex; 0; end
7587 ##
7588 # Treats leading characters of <i>str</i> as a string of octal digits (with an
7589 # optional sign) and returns the corresponding number.  Returns 0 if the
7590 # conversion fails.
7591 # 
7592 #    "123".oct       #=> 83
7593 #    "-377".oct      #=> -255
7594 #    "bad".oct       #=> 0
7595 #    "0377bad".oct   #=> 255
7596 def oct; 0; end
7597 ##
7598 # Divides <i>str</i> into substrings based on a delimiter, returning an array
7599 # of these substrings.
7600 # 
7601 # If <i>pattern</i> is a <code>String</code>, then its contents are used as
7602 # the delimiter when splitting <i>str</i>. If <i>pattern</i> is a single
7603 # space, <i>str</i> is split on whitespace, with leading whitespace and runs
7604 # of contiguous whitespace characters ignored.
7605 # 
7606 # If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the
7607 # pattern matches. Whenever the pattern matches a zero-length string,
7608 # <i>str</i> is split into individual characters. If <i>pattern</i> contains
7609 # groups, the respective matches will be returned in the array as well.
7610 # 
7611 # If <i>pattern</i> is omitted, the value of <code>$;</code> is used.  If
7612 # <code>$;</code> is <code>nil</code> (which is the default), <i>str</i> is
7613 # split on whitespace as if ` ' were specified.
7614 # 
7615 # If the <i>limit</i> parameter is omitted, trailing null fields are
7616 # suppressed. If <i>limit</i> is a positive number, at most that number of
7617 # fields will be returned (if <i>limit</i> is <code>1</code>, the entire
7618 # string is returned as the only entry in an array). If negative, there is no
7619 # limit to the number of fields returned, and trailing null fields are not
7620 # suppressed.
7621 # 
7622 # When the input +str+ is empty an empty Array is returned as the string is
7623 # considered to have no fields to split.
7624 # 
7625 #    " now's  the time".split        #=> ["now's", "the", "time"]
7626 #    " now's  the time".split(' ')   #=> ["now's", "the", "time"]
7627 #    " now's  the time".split(/ /)   #=> ["", "now's", "", "the", "time"]
7628 #    "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"]
7629 #    "hello".split(//)               #=> ["h", "e", "l", "l", "o"]
7630 #    "hello".split(//, 3)            #=> ["h", "e", "llo"]
7631 #    "hi mom".split(%r{\s*})         #=> ["h", "i", "m", "o", "m"]
7632 # 
7633 #    "mellow yellow".split("ello")   #=> ["m", "w y", "w"]
7634 #    "1,2,,3,4,,".split(',')         #=> ["1", "2", "", "3", "4"]
7635 #    "1,2,,3,4,,".split(',', 4)      #=> ["1", "2", "", "3,4,,"]
7636 #    "1,2,,3,4,,".split(',', -4)     #=> ["1", "2", "", "3", "4", "", ""]
7637 # 
7638 #    "".split(',', -1)               #=> []
7639 def split(pattern=$;, limit=0); []; end
7640 ##
7641 # Returns an array of lines in <i>str</i> split using the supplied
7642 # record separator (<code>$/</code> by default).  This is a
7643 # shorthand for <code>str.each_line(separator).to_a</code>.
7644 # 
7645 # If a block is given, which is a deprecated form, works the same as
7646 # <code>each_line</code>.
7647 def lines(separator=$/); []; end
7648 ##
7649 # Returns an array of bytes in <i>str</i>.  This is a shorthand for
7650 # <code>str.each_byte.to_a</code>.
7651 # 
7652 # If a block is given, which is a deprecated form, works the same as
7653 # <code>each_byte</code>.
7654 def bytes; []; end
7655 ##
7656 # Returns an array of characters in <i>str</i>.  This is a shorthand
7657 # for <code>str.each_char.to_a</code>.
7658 # 
7659 # If a block is given, which is a deprecated form, works the same as
7660 # <code>each_char</code>.
7661 def chars; []; end
7662 ##
7663 # Returns an array of the <code>Integer</code> ordinals of the
7664 # characters in <i>str</i>.  This is a shorthand for
7665 # <code>str.each_codepoint.to_a</code>.
7666 # 
7667 # If a block is given, which is a deprecated form, works the same as
7668 # <code>each_codepoint</code>.
7669 def codepoints; []; end
7670 ##
7671 # Returns a new string with the characters from <i>str</i> in reverse order.
7672 # 
7673 #    "stressed".reverse   #=> "desserts"
7674 def reverse; ''; end
7675 ##
7676 # Reverses <i>str</i> in place.
7677 def reverse!; ''; end
7678 ##
7679 # Append---Concatenates the given object to <i>str</i>. If the object is a
7680 # <code>Integer</code>, it is considered as a codepoint, and is converted
7681 # to a character before concatenation.
7682 # 
7683 #    a = "hello "
7684 #    a << "world"   #=> "hello world"
7685 #    a.concat(33)   #=> "hello world!"
7686 def concat; ''; end
7687 ##
7688 # Append---Concatenates the given object to <i>str</i>. If the object is a
7689 # <code>Integer</code>, it is considered as a codepoint, and is converted
7690 # to a character before concatenation.
7691 # 
7692 #    a = "hello "
7693 #    a << "world"   #=> "hello world"
7694 #    a.concat(33)   #=> "hello world!"
7695 def <<; ''; end
7696 ##
7697 # Prepend---Prepend the given string to <i>str</i>.
7698 # 
7699 #    a = "world"
7700 #    a.prepend("hello ") #=> "hello world"
7701 #    a                   #=> "hello world"
7702 def prepend(other_str); ''; end
7703 ##
7704 # Applies a one-way cryptographic hash to <i>str</i> by invoking the
7705 # standard library function <code>crypt(3)</code> with the given
7706 # salt string.  While the format and the result are system and
7707 # implementation dependent, using a salt matching the regular
7708 # expression <code>\A[a-zA-Z0-9./]{2}</code> should be valid and
7709 # safe on any platform, in which only the first two characters are
7710 # significant.
7711 # 
7712 # This method is for use in system specific scripts, so if you want
7713 # a cross-platform hash function consider using Digest or OpenSSL
7714 # instead.
7715 def crypt(salt_str); ''; end
7716 ##
7717 # Returns the <code>Symbol</code> corresponding to <i>str</i>, creating the
7718 # symbol if it did not previously exist. See <code>Symbol#id2name</code>.
7719 # 
7720 #    "Koala".intern         #=> :Koala
7721 #    s = 'cat'.to_sym       #=> :cat
7722 #    s == :cat              #=> true
7723 #    s = '@cat'.to_sym      #=> :@cat
7724 #    s == :@cat             #=> true
7725 # 
7726 # This can also be used to create symbols that cannot be represented using the
7727 # <code>:xxx</code> notation.
7728 # 
7729 #    'cat and dog'.to_sym   #=> :"cat and dog"
7730 def intern; :a; end
7731 ##
7732 # Returns the <code>Symbol</code> corresponding to <i>str</i>, creating the
7733 # symbol if it did not previously exist. See <code>Symbol#id2name</code>.
7734 # 
7735 #    "Koala".intern         #=> :Koala
7736 #    s = 'cat'.to_sym       #=> :cat
7737 #    s == :cat              #=> true
7738 #    s = '@cat'.to_sym      #=> :@cat
7739 #    s == :@cat             #=> true
7740 # 
7741 # This can also be used to create symbols that cannot be represented using the
7742 # <code>:xxx</code> notation.
7743 # 
7744 #    'cat and dog'.to_sym   #=> :"cat and dog"
7745 def to_sym; :a; end
7746 ##
7747 # Return the <code>Integer</code> ordinal of a one-character string.
7748 # 
7749 #    "a".ord         #=> 97
7750 def ord; 0; end
7751 ##
7752 # Returns <code>true</code> if <i>str</i> contains the given string or
7753 # character.
7754 # 
7755 #    "hello".include? "lo"   #=> true
7756 #    "hello".include? "ol"   #=> false
7757 #    "hello".include? ?h     #=> true
7758 def include? other_str; true || false; end
7759 ##
7760 # Returns true if +str+ starts with one of the +prefixes+ given.
7761 # 
7762 #   "hello".start_with?("hell")               #=> true
7763 # 
7764 #   # returns true if one of the prefixes matches.
7765 #   "hello".start_with?("heaven", "hell")     #=> true
7766 #   "hello".start_with?("heaven", "paradise") #=> false
7767 def start_with?(); true || false; end
7768 ##
7769 # Returns true if +str+ ends with one of the +suffixes+ given.
7770 def end_with?(); true || false; end
7771 ##
7772 # Both forms iterate through <i>str</i>, matching the pattern (which may be a
7773 # <code>Regexp</code> or a <code>String</code>). For each match, a result is
7774 # generated and either added to the result array or passed to the block. If
7775 # the pattern contains no groups, each individual result consists of the
7776 # matched string, <code>$&</code>.  If the pattern contains groups, each
7777 # individual result is itself an array containing one entry per group.
7778 # 
7779 #    a = "cruel world"
7780 #    a.scan(/\w+/)        #=> ["cruel", "world"]
7781 #    a.scan(/.../)        #=> ["cru", "el ", "wor"]
7782 #    a.scan(/(...)/)      #=> [["cru"], ["el "], ["wor"]]
7783 #    a.scan(/(..)(..)/)   #=> [["cr", "ue"], ["l ", "wo"]]
7784 # 
7785 # And the block form:
7786 # 
7787 #    a.scan(/\w+/) {|w| print "<<#{w}>> " }
7788 #    print "\n"
7789 #    a.scan(/(.)(.)/) {|x,y| print y, x }
7790 #    print "\n"
7791 # 
7792 # <em>produces:</em>
7793 # 
7794 #    <<cruel>> <<world>>
7795 #    rceu lowlr
7796 def scan(pattern); ''; end
7797 ##
7798 # If <i>integer</i> is greater than the length of <i>str</i>, returns a new
7799 # <code>String</code> of length <i>integer</i> with <i>str</i> left justified
7800 # and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
7801 # 
7802 #    "hello".ljust(4)            #=> "hello"
7803 #    "hello".ljust(20)           #=> "hello               "
7804 #    "hello".ljust(20, '1234')   #=> "hello123412341234123"
7805 def ljust(integer, padstr=' '); ''; end
7806 ##
7807 # If <i>integer</i> is greater than the length of <i>str</i>, returns a new
7808 # <code>String</code> of length <i>integer</i> with <i>str</i> right justified
7809 # and padded with <i>padstr</i>; otherwise, returns <i>str</i>.
7810 # 
7811 #    "hello".rjust(4)            #=> "hello"
7812 #    "hello".rjust(20)           #=> "               hello"
7813 #    "hello".rjust(20, '1234')   #=> "123412341234123hello"
7814 def rjust(integer, padstr=' '); ''; end
7815 ##
7816 # Centers +str+ in +width+.  If +width+ is greater than the length of +str+,
7817 # returns a new String of length +width+ with +str+ centered and padded with
7818 # +padstr+; otherwise, returns +str+.
7819 # 
7820 #    "hello".center(4)         #=> "hello"
7821 #    "hello".center(20)        #=> "       hello        "
7822 #    "hello".center(20, '123') #=> "1231231hello12312312"
7823 def center(width, padstr=' '); ''; end
7824 ##
7825 # Returns a copy of +str+ with the _first_ occurrence of +pattern+
7826 # replaced by the second argument. The +pattern+ is typically a Regexp; if
7827 # given as a String, any regular expression metacharacters it contains will
7828 # be interpreted literally, e.g. <code>'\\\d'</code> will match a backlash
7829 # followed by 'd', instead of a digit.
7830 # 
7831 # If +replacement+ is a String it will be substituted for the matched text.
7832 # It may contain back-references to the pattern's capture groups of the form
7833 # <code>"\\d"</code>, where <i>d</i> is a group number, or
7834 # <code>"\\k<n>"</code>, where <i>n</i> is a group name. If it is a
7835 # double-quoted string, both back-references must be preceded by an
7836 # additional backslash. However, within +replacement+ the special match
7837 # variables, such as <code>&$</code>, will not refer to the current match.
7838 # 
7839 # If the second argument is a Hash, and the matched text is one of its keys,
7840 # the corresponding value is the replacement string.
7841 # 
7842 # In the block form, the current match string is passed in as a parameter,
7843 # and variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
7844 # <code>$&</code>, and <code>$'</code> will be set appropriately. The value
7845 # returned by the block will be substituted for the match on each call.
7846 # 
7847 # The result inherits any tainting in the original string or any supplied
7848 # replacement string.
7849 # 
7850 #    "hello".sub(/[aeiou]/, '*')                  #=> "h*llo"
7851 #    "hello".sub(/([aeiou])/, '<\1>')             #=> "h<e>llo"
7852 #    "hello".sub(/./) {|s| s.ord.to_s + ' ' }     #=> "104 ello"
7853 #    "hello".sub(/(?<foo>[aeiou])/, '*\k<foo>*')  #=> "h*e*llo"
7854 #    'Is SHELL your preferred shell?'.sub(/[[:upper:]]{2,}/, ENV)
7855 #     #=> "Is /bin/bash your preferred shell?"
7856 def sub(pattern, replacement); ''; end
7857 ##
7858 # Returns a copy of <i>str</i> with the <em>all</em> occurrences of
7859 # <i>pattern</i> substituted for the second argument. The <i>pattern</i> is
7860 # typically a <code>Regexp</code>; if given as a <code>String</code>, any
7861 # regular expression metacharacters it contains will be interpreted
7862 # literally, e.g. <code>'\\\d'</code> will match a backlash followed by 'd',
7863 # instead of a digit.
7864 # 
7865 # If <i>replacement</i> is a <code>String</code> it will be substituted for
7866 # the matched text. It may contain back-references to the pattern's capture
7867 # groups of the form <code>\\\d</code>, where <i>d</i> is a group number, or
7868 # <code>\\\k<n></code>, where <i>n</i> is a group name. If it is a
7869 # double-quoted string, both back-references must be preceded by an
7870 # additional backslash. However, within <i>replacement</i> the special match
7871 # variables, such as <code>&$</code>, will not refer to the current match.
7872 # 
7873 # If the second argument is a <code>Hash</code>, and the matched text is one
7874 # of its keys, the corresponding value is the replacement string.
7875 # 
7876 # In the block form, the current match string is passed in as a parameter,
7877 # and variables such as <code>$1</code>, <code>$2</code>, <code>$`</code>,
7878 # <code>$&</code>, and <code>$'</code> will be set appropriately. The value
7879 # returned by the block will be substituted for the match on each call.
7880 # 
7881 # The result inherits any tainting in the original string or any supplied
7882 # replacement string.
7883 # 
7884 # When neither a block nor a second argument is supplied, an
7885 # <code>Enumerator</code> is returned.
7886 # 
7887 #    "hello".gsub(/[aeiou]/, '*')                  #=> "h*ll*"
7888 #    "hello".gsub(/([aeiou])/, '<\1>')             #=> "h<e>ll<o>"
7889 #    "hello".gsub(/./) {|s| s.ord.to_s + ' '}      #=> "104 101 108 108 111 "
7890 #    "hello".gsub(/(?<foo>[aeiou])/, '{\k<foo>}')  #=> "h{e}ll{o}"
7891 #    'hello'.gsub(/[eo]/, 'e' => 3, 'o' => '*')    #=> "h3ll*"
7892 def gsub(pattern, replacement); Enumerator.new; end
7893 ##
7894 # Returns a new <code>String</code> with the last character removed.  If the
7895 # string ends with <code>\r\n</code>, both characters are removed. Applying
7896 # <code>chop</code> to an empty string returns an empty
7897 # string. <code>String#chomp</code> is often a safer alternative, as it leaves
7898 # the string unchanged if it doesn't end in a record separator.
7899 # 
7900 #    "string\r\n".chop   #=> "string"
7901 #    "string\n\r".chop   #=> "string\n"
7902 #    "string\n".chop     #=> "string"
7903 #    "string".chop       #=> "strin"
7904 #    "x".chop.chop       #=> ""
7905 def chop; ''; end
7906 ##
7907 # Returns a new <code>String</code> with the given record separator removed
7908 # from the end of <i>str</i> (if present). If <code>$/</code> has not been
7909 # changed from the default Ruby record separator, then <code>chomp</code> also
7910 # removes carriage return characters (that is it will remove <code>\n</code>,
7911 # <code>\r</code>, and <code>\r\n</code>).
7912 # 
7913 #    "hello".chomp            #=> "hello"
7914 #    "hello\n".chomp          #=> "hello"
7915 #    "hello\r\n".chomp        #=> "hello"
7916 #    "hello\n\r".chomp        #=> "hello\n"
7917 #    "hello\r".chomp          #=> "hello"
7918 #    "hello \n there".chomp   #=> "hello \n there"
7919 #    "hello".chomp("llo")     #=> "he"
7920 def chomp(separator=$/); ''; end
7921 ##
7922 # Returns a copy of <i>str</i> with leading and trailing whitespace removed.
7923 # 
7924 #    "    hello    ".strip   #=> "hello"
7925 #    "\tgoodbye\r\n".strip   #=> "goodbye"
7926 def strip; ''; end
7927 ##
7928 # Returns a copy of <i>str</i> with leading whitespace removed. See also
7929 # <code>String#rstrip</code> and <code>String#strip</code>.
7930 # 
7931 #    "  hello  ".lstrip   #=> "hello  "
7932 #    "hello".lstrip       #=> "hello"
7933 def lstrip; ''; end
7934 ##
7935 # Returns a copy of <i>str</i> with trailing whitespace removed. See also
7936 # <code>String#lstrip</code> and <code>String#strip</code>.
7937 # 
7938 #    "  hello  ".rstrip   #=> "  hello"
7939 #    "hello".rstrip       #=> "hello"
7940 def rstrip; ''; end
7941 ##
7942 # Performs the same substitution as String#sub in-place.
7943 # 
7944 # Returns +str+ if a substitution was performed or +nil+ if no substitution
7945 # was performed.
7946 def sub!(pattern, replacement); '' || nil; end
7947 ##
7948 # Performs the substitutions of <code>String#gsub</code> in place, returning
7949 # <i>str</i>, or <code>nil</code> if no substitutions were performed.
7950 # If no block and no <i>replacement</i> is given, an enumerator is returned instead.
7951 def gsub!(pattern, replacement); Enumerator.new; end
7952 ##
7953 # Processes <i>str</i> as for <code>String#chop</code>, returning <i>str</i>,
7954 # or <code>nil</code> if <i>str</i> is the empty string.  See also
7955 # <code>String#chomp!</code>.
7956 def chop!; '' || nil; end
7957 ##
7958 # Modifies <i>str</i> in place as described for <code>String#chomp</code>,
7959 # returning <i>str</i>, or <code>nil</code> if no modifications were made.
7960 def chomp!(separator=$/); '' || nil; end
7961 ##
7962 # Removes leading and trailing whitespace from <i>str</i>. Returns
7963 # <code>nil</code> if <i>str</i> was not altered.
7964 def strip!; '' || nil; end
7965 ##
7966 # Removes leading whitespace from <i>str</i>, returning <code>nil</code> if no
7967 # change was made. See also <code>String#rstrip!</code> and
7968 # <code>String#strip!</code>.
7969 # 
7970 #    "  hello  ".lstrip   #=> "hello  "
7971 #    "hello".lstrip!      #=> nil
7972 def lstrip!; self || nil; end
7973 ##
7974 # Removes trailing whitespace from <i>str</i>, returning <code>nil</code> if
7975 # no change was made. See also <code>String#lstrip!</code> and
7976 # <code>String#strip!</code>.
7977 # 
7978 #    "  hello  ".rstrip   #=> "  hello"
7979 #    "hello".rstrip!      #=> nil
7980 def rstrip!; self || nil; end
7981 ##
7982 # Returns a copy of +str+ with the characters in +from_str+ replaced by the
7983 # corresponding characters in +to_str+.  If +to_str+ is shorter than
7984 # +from_str+, it is padded with its last character in order to maintain the
7985 # correspondence.
7986 # 
7987 #    "hello".tr('el', 'ip')      #=> "hippo"
7988 #    "hello".tr('aeiou', '*')    #=> "h*ll*"
7989 #    "hello".tr('aeiou', 'AA*')  #=> "hAll*"
7990 # 
7991 # Both strings may use the <code>c1-c2</code> notation to denote ranges of
7992 # characters, and +from_str+ may start with a <code>^</code>, which denotes
7993 # all characters except those listed.
7994 # 
7995 #    "hello".tr('a-y', 'b-z')    #=> "ifmmp"
7996 #    "hello".tr('^aeiou', '*')   #=> "*e**o"
7997 # 
7998 # The backslash character <code>\</code> can be used to escape
7999 # <code>^</code> or <code>-</code> and is otherwise ignored unless it
8000 # appears at the end of a range or the end of the +from_str+ or +to_str+:
8001 # 
8002 #    "hello^world".tr("\\^aeiou", "*") #=> "h*ll**w*rld"
8003 #    "hello-world".tr("a\\-eo", "*")   #=> "h*ll**w*rld"
8004 # 
8005 #    "hello\r\nworld".tr("\r", "")   #=> "hello\nworld"
8006 #    "hello\r\nworld".tr("\\r", "")  #=> "hello\r\nwold"
8007 #    "hello\r\nworld".tr("\\\r", "") #=> "hello\nworld"
8008 # 
8009 #    "X['\\b']".tr("X\\", "")   #=> "['b']"
8010 #    "X['\\b']".tr("X-\\]", "") #=> "'b'"
8011 def tr(from_str, to_str); ''; end
8012 ##
8013 # Processes a copy of <i>str</i> as described under <code>String#tr</code>,
8014 # then removes duplicate characters in regions that were affected by the
8015 # translation.
8016 # 
8017 #    "hello".tr_s('l', 'r')     #=> "hero"
8018 #    "hello".tr_s('el', '*')    #=> "h*o"
8019 #    "hello".tr_s('el', 'hx')   #=> "hhxo"
8020 def tr_s(from_str, to_str); ''; end
8021 ##
8022 # Returns a copy of <i>str</i> with all characters in the intersection of its
8023 # arguments deleted. Uses the same rules for building the set of characters as
8024 # <code>String#count</code>.
8025 # 
8026 #    "hello".delete "l","lo"        #=> "heo"
8027 #    "hello".delete "lo"            #=> "he"
8028 #    "hello".delete "aeiou", "^e"   #=> "hell"
8029 #    "hello".delete "ej-m"          #=> "ho"
8030 def delete(); ''; end
8031 ##
8032 # Builds a set of characters from the <i>other_str</i> parameter(s) using the
8033 # procedure described for <code>String#count</code>. Returns a new string
8034 # where runs of the same character that occur in this set are replaced by a
8035 # single character. If no arguments are given, all runs of identical
8036 # characters are replaced by a single character.
8037 # 
8038 #    "yellow moon".squeeze                  #=> "yelow mon"
8039 #    "  now   is  the".squeeze(" ")         #=> " now is the"
8040 #    "putters shoot balls".squeeze("m-z")   #=> "puters shot balls"
8041 def squeeze(); ''; end
8042 ##
8043 # Each +other_str+ parameter defines a set of characters to count.  The
8044 # intersection of these sets defines the characters to count in +str+.  Any
8045 # +other_str+ that starts with a caret <code>^</code> is negated.  The
8046 # sequence <code>c1-c2</code> means all characters between c1 and c2.  The
8047 # backslash character <code>\</code> can be used to escape <code>^</code> or
8048 # <code>-</code> and is otherwise ignored unless it appears at the end of a
8049 # sequence or the end of a +other_str+.
8050 # 
8051 #    a = "hello world"
8052 #    a.count "lo"                   #=> 5
8053 #    a.count "lo", "o"              #=> 2
8054 #    a.count "hello", "^l"          #=> 4
8055 #    a.count "ej-m"                 #=> 4
8056 # 
8057 #    "hello^world".count "\\^aeiou" #=> 4
8058 #    "hello-world".count "a\\-eo"   #=> 4
8059 # 
8060 #    c = "hello world\\r\\n"
8061 #    c.count "\\"                   #=> 2
8062 #    c.count "\\A"                  #=> 0
8063 #    c.count "X-\\w"                #=> 3
8064 def count(); 0; end
8065 ##
8066 # Translates <i>str</i> in place, using the same rules as
8067 # <code>String#tr</code>. Returns <i>str</i>, or <code>nil</code> if no
8068 # changes were made.
8069 def tr!(from_str, to_str); '' || nil; end
8070 ##
8071 # Performs <code>String#tr_s</code> processing on <i>str</i> in place,
8072 # returning <i>str</i>, or <code>nil</code> if no changes were made.
8073 def tr_s!(from_str, to_str); '' || nil; end
8074 ##
8075 # Performs a <code>delete</code> operation in place, returning <i>str</i>, or
8076 # <code>nil</code> if <i>str</i> was not modified.
8077 def delete!(); '' || nil; end
8078 ##
8079 # Squeezes <i>str</i> in place, returning either <i>str</i>, or
8080 # <code>nil</code> if no changes were made.
8081 def squeeze!(); '' || nil; end
8082 ##
8083 # Splits <i>str</i> using the supplied parameter as the record
8084 # separator (<code>$/</code> by default), passing each substring in
8085 # turn to the supplied block.  If a zero-length record separator is
8086 # supplied, the string is split into paragraphs delimited by
8087 # multiple successive newlines.
8088 # 
8089 # If no block is given, an enumerator is returned instead.
8090 # 
8091 #    print "Example one\n"
8092 #    "hello\nworld".each_line {|s| p s}
8093 #    print "Example two\n"
8094 #    "hello\nworld".each_line('l') {|s| p s}
8095 #    print "Example three\n"
8096 #    "hello\n\n\nworld".each_line('') {|s| p s}
8097 # 
8098 # <em>produces:</em>
8099 # 
8100 #    Example one
8101 #    "hello\n"
8102 #    "world"
8103 #    Example two
8104 #    "hel"
8105 #    "l"
8106 #    "o\nworl"
8107 #    "d"
8108 #    Example three
8109 #    "hello\n\n\n"
8110 #    "world"
8111 def each_line(separator=$/, &block); Enumerator.new; end
8112 ##
8113 # Passes each byte in <i>str</i> to the given block, or returns an
8114 # enumerator if no block is given.
8115 # 
8116 #    "hello".each_byte {|c| print c, ' ' }
8117 # 
8118 # <em>produces:</em>
8119 # 
8120 #    104 101 108 108 111
8121 def each_byte(&block); Enumerator.new; end
8122 ##
8123 # Passes each character in <i>str</i> to the given block, or returns
8124 # an enumerator if no block is given.
8125 # 
8126 #    "hello".each_char {|c| print c, ' ' }
8127 # 
8128 # <em>produces:</em>
8129 # 
8130 #    h e l l o
8131 def each_char(&block); Enumerator.new; end
8132 ##
8133 # Passes the <code>Integer</code> ordinal of each character in <i>str</i>,
8134 # also known as a <i>codepoint</i> when applied to Unicode strings to the
8135 # given block.
8136 # 
8137 # If no block is given, an enumerator is returned instead.
8138 # 
8139 #    "hello\u0639".each_codepoint {|c| print c, ' ' }
8140 # 
8141 # <em>produces:</em>
8142 # 
8143 #    104 101 108 108 111 1593
8144 def each_codepoint(&block); Enumerator.new; end
8145 ##
8146 # Returns a basic <em>n</em>-bit checksum of the characters in <i>str</i>,
8147 # where <em>n</em> is the optional <code>Fixnum</code> parameter, defaulting
8148 # to 16. The result is simply the sum of the binary value of each character in
8149 # <i>str</i> modulo <code>2**n - 1</code>. This is not a particularly good
8150 # checksum.
8151 def sum(n=16); 0; end
8152 ##
8153 # Deletes the specified portion from <i>str</i>, and returns the portion
8154 # deleted.
8155 # 
8156 #    string = "this is a string"
8157 #    string.slice!(2)        #=> "i"
8158 #    string.slice!(3..6)     #=> " is "
8159 #    string.slice!(/s.*t/)   #=> "sa st"
8160 #    string.slice!("r")      #=> "r"
8161 #    string                  #=> "thing"
8162 def slice!(fixnum); '' || nil; end
8163 ##
8164 # Searches <i>sep</i> or pattern (<i>regexp</i>) in the string
8165 # and returns the part before it, the match, and the part
8166 # after it.
8167 # If it is not found, returns two empty strings and <i>str</i>.
8168 # 
8169 #    "hello".partition("l")         #=> ["he", "l", "lo"]
8170 #    "hello".partition("x")         #=> ["hello", "", ""]
8171 #    "hello".partition(/.l/)        #=> ["h", "el", "lo"]
8172 def partition(sep); []; end
8173 ##
8174 # Searches <i>sep</i> or pattern (<i>regexp</i>) in the string from the end
8175 # of the string, and returns the part before it, the match, and the part
8176 # after it.
8177 # If it is not found, returns two empty strings and <i>str</i>.
8178 # 
8179 #    "hello".rpartition("l")         #=> ["hel", "l", "o"]
8180 #    "hello".rpartition("x")         #=> ["", "", "hello"]
8181 #    "hello".rpartition(/.l/)        #=> ["he", "ll", "o"]
8182 def rpartition(sep); []; end
8183 ##
8184 # Returns the Encoding object that represents the encoding of obj.
8185 def encoding; Encoding.new; end
8186 ##
8187 # Changes the encoding to +encoding+ and returns self.
8188 def force_encoding(encoding); ''; end
8189 ##
8190 # Returns a copied string whose encoding is ASCII-8BIT.
8191 def b; ''; end
8192 ##
8193 # Returns true for a string which encoded correctly.
8194 # 
8195 #   "\xc2\xa1".force_encoding("UTF-8").valid_encoding?  #=> true
8196 #   "\xc2".force_encoding("UTF-8").valid_encoding?      #=> false
8197 #   "\x80".force_encoding("UTF-8").valid_encoding?      #=> false
8198 def valid_encoding?; true || false; end
8199 ##
8200 # Returns true for a string which has only ASCII characters.
8201 # 
8202 #   "abc".force_encoding("UTF-8").ascii_only?          #=> true
8203 #   "abc\u{6666}".force_encoding("UTF-8").ascii_only?  #=> false
8204 def ascii_only?; true || false; end
8205 ##
8206 # Returns a rational which denotes the string form.  The parser
8207 # ignores leading whitespaces and trailing garbage.  Any digit
8208 # sequences can be separated by an underscore.  Returns zero for null
8209 # or garbage string.
8210 # 
8211 # NOTE: '0.3'.to_r isn't the same as 0.3.to_r.  The former is
8212 # equivalent to '3/10'.to_r, but the latter isn't so.
8213 # 
8214 #    '  2  '.to_r       #=> (2/1)
8215 #    '300/2'.to_r       #=> (150/1)
8216 #    '-9.2'.to_r        #=> (-46/5)
8217 #    '-9.2e2'.to_r      #=> (-920/1)
8218 #    '1_234_567'.to_r   #=> (1234567/1)
8219 #    '21 june 09'.to_r  #=> (21/1)
8220 #    '21/06/09'.to_r    #=> (7/2)
8221 #    'bwv 1079'.to_r    #=> (0/1)
8222 # 
8223 # See Kernel.Rational.
8224 def to_r; Rational.new; end
8225 ##
8226 # The first form returns a copy of +str+ transcoded
8227 # to encoding +encoding+.
8228 # The second form returns a copy of +str+ transcoded
8229 # from src_encoding to dst_encoding.
8230 # The last form returns a copy of +str+ transcoded to
8231 # <tt>Encoding.default_internal</tt>.
8232 # 
8233 # By default, the first and second form raise
8234 # Encoding::UndefinedConversionError for characters that are
8235 # undefined in the destination encoding, and
8236 # Encoding::InvalidByteSequenceError for invalid byte sequences
8237 # in the source encoding. The last form by default does not raise
8238 # exceptions but uses replacement strings.
8239 # 
8240 # Please note that conversion from an encoding +enc+ to the
8241 # same encoding +enc+ is a no-op, i.e. the receiver is returned without
8242 # any changes, and no exceptions are raised, even if there are invalid bytes.
8243 # 
8244 # The +options+ Hash gives details for conversion and can have the following
8245 # keys:
8246 # 
8247 # :invalid ::
8248 #   If the value is +:replace+, #encode replaces invalid byte sequences in
8249 #   +str+ with the replacement character.  The default is to raise the
8250 #   Encoding::InvalidByteSequenceError exception
8251 # :undef ::
8252 #   If the value is +:replace+, #encode replaces characters which are
8253 #   undefined in the destination encoding with the replacement character.
8254 #   The default is to raise the Encoding::UndefinedConversionError.
8255 # :replace ::
8256 #   Sets the replacement string to the given value. The default replacement
8257 #   string is "\uFFFD" for Unicode encoding forms, and "?" otherwise.
8258 # :fallback ::
8259 #   Sets the replacement string by the given object for undefined
8260 #   character.  The object should be a Hash, a Proc, a Method, or an
8261 #   object which has [] method.
8262 #   Its key is an undefined character encoded in the source encoding
8263 #   of current transcoder. Its value can be any encoding until it
8264 #   can be converted into the destination encoding of the transcoder.
8265 # :xml ::
8266 #   The value must be +:text+ or +:attr+.
8267 #   If the value is +:text+ #encode replaces undefined characters with their
8268 #   (upper-case hexadecimal) numeric character references. '&', '<', and '>'
8269 #   are converted to "&amp;", "&lt;", and "&gt;", respectively.
8270 #   If the value is +:attr+, #encode also quotes the replacement result
8271 #   (using '"'), and replaces '"' with "&quot;".
8272 # :cr_newline ::
8273 #   Replaces LF ("\n") with CR ("\r") if value is true.
8274 # :crlf_newline ::
8275 #   Replaces LF ("\n") with CRLF ("\r\n") if value is true.
8276 # :universal_newline ::
8277 #   Replaces CRLF ("\r\n") and CR ("\r") with LF ("\n") if value is true.
8278 def encode(encoding  , options=0); ''; end
8279 ##
8280 # The first form transcodes the contents of <i>str</i> from
8281 # str.encoding to +encoding+.
8282 # The second form transcodes the contents of <i>str</i> from
8283 # src_encoding to dst_encoding.
8284 # The options Hash gives details for conversion. See String#encode
8285 # for details.
8286 # Returns the string even if no changes were made.
8287 def encode!(encoding  , options=0); ''; end
8288 ##
8289 # Decodes <i>str</i> (which may contain binary data) according to the
8290 # format string, returning an array of each value extracted. The
8291 # format string consists of a sequence of single-character directives,
8292 # summarized in the table at the end of this entry.
8293 # Each directive may be followed
8294 # by a number, indicating the number of times to repeat with this
8295 # directive. An asterisk (``<code>*</code>'') will use up all
8296 # remaining elements. The directives <code>sSiIlL</code> may each be
8297 # followed by an underscore (``<code>_</code>'') or
8298 # exclamation mark (``<code>!</code>'') to use the underlying
8299 # platform's native size for the specified type; otherwise, it uses a
8300 # platform-independent consistent size. Spaces are ignored in the
8301 # format string. See also <code>Array#pack</code>.
8302 # 
8303 #    "abc \0\0abc \0\0".unpack('A6Z6')   #=> ["abc", "abc "]
8304 #    "abc \0\0".unpack('a3a3')           #=> ["abc", " \000\000"]
8305 #    "abc \0abc \0".unpack('Z*Z*')       #=> ["abc ", "abc "]
8306 #    "aa".unpack('b8B8')                 #=> ["10000110", "01100001"]
8307 #    "aaa".unpack('h2H2c')               #=> ["16", "61", 97]
8308 #    "\xfe\xff\xfe\xff".unpack('sS')     #=> [-2, 65534]
8309 #    "now=20is".unpack('M*')             #=> ["now is"]
8310 #    "whole".unpack('xax2aX2aX1aX2a')    #=> ["h", "e", "l", "l", "o"]
8311 # 
8312 # This table summarizes the various formats and the Ruby classes
8313 # returned by each.
8314 # 
8315 #  Integer      |         |
8316 #  Directive    | Returns | Meaning
8317 #  -----------------------------------------------------------------
8318 #     C         | Integer | 8-bit unsigned (unsigned char)
8319 #     S         | Integer | 16-bit unsigned, native endian (uint16_t)
8320 #     L         | Integer | 32-bit unsigned, native endian (uint32_t)
8321 #     Q         | Integer | 64-bit unsigned, native endian (uint64_t)
8322 #               |         |
8323 #     c         | Integer | 8-bit signed (signed char)
8324 #     s         | Integer | 16-bit signed, native endian (int16_t)
8325 #     l         | Integer | 32-bit signed, native endian (int32_t)
8326 #     q         | Integer | 64-bit signed, native endian (int64_t)
8327 #               |         |
8328 #     S_, S!    | Integer | unsigned short, native endian
8329 #     I, I_, I! | Integer | unsigned int, native endian
8330 #     L_, L!    | Integer | unsigned long, native endian
8331 #               |         |
8332 #     s_, s!    | Integer | signed short, native endian
8333 #     i, i_, i! | Integer | signed int, native endian
8334 #     l_, l!    | Integer | signed long, native endian
8335 #               |         |
8336 #     S> L> Q>  | Integer | same as the directives without ">" except
8337 #     s> l> q>  |         | big endian
8338 #     S!> I!>   |         | (available since Ruby 1.9.3)
8339 #     L!> Q!>   |         | "S>" is same as "n"
8340 #     s!> i!>   |         | "L>" is same as "N"
8341 #     l!> q!>   |         |
8342 #               |         |
8343 #     S< L< Q<  | Integer | same as the directives without "<" except
8344 #     s< l< q<  |         | little endian
8345 #     S!< I!<   |         | (available since Ruby 1.9.3)
8346 #     L!< Q!<   |         | "S<" is same as "v"
8347 #     s!< i!<   |         | "L<" is same as "V"
8348 #     l!< q!<   |         |
8349 #               |         |
8350 #     n         | Integer | 16-bit unsigned, network (big-endian) byte order
8351 #     N         | Integer | 32-bit unsigned, network (big-endian) byte order
8352 #     v         | Integer | 16-bit unsigned, VAX (little-endian) byte order
8353 #     V         | Integer | 32-bit unsigned, VAX (little-endian) byte order
8354 #               |         |
8355 #     U         | Integer | UTF-8 character
8356 #     w         | Integer | BER-compressed integer (see Array.pack)
8357 # 
8358 #  Float        |         |
8359 #  Directive    | Returns | Meaning
8360 #  -----------------------------------------------------------------
8361 #     D, d      | Float   | double-precision, native format
8362 #     F, f      | Float   | single-precision, native format
8363 #     E         | Float   | double-precision, little-endian byte order
8364 #     e         | Float   | single-precision, little-endian byte order
8365 #     G         | Float   | double-precision, network (big-endian) byte order
8366 #     g         | Float   | single-precision, network (big-endian) byte order
8367 # 
8368 #  String       |         |
8369 #  Directive    | Returns | Meaning
8370 #  -----------------------------------------------------------------
8371 #     A         | String  | arbitrary binary string (remove trailing nulls and ASCII spaces)
8372 #     a         | String  | arbitrary binary string
8373 #     Z         | String  | null-terminated string
8374 #     B         | String  | bit string (MSB first)
8375 #     b         | String  | bit string (LSB first)
8376 #     H         | String  | hex string (high nibble first)
8377 #     h         | String  | hex string (low nibble first)
8378 #     u         | String  | UU-encoded string
8379 #     M         | String  | quoted-printable, MIME encoding (see RFC2045)
8380 #     m         | String  | base64 encoded string (RFC 2045) (default)
8381 #               |         | base64 encoded string (RFC 4648) if followed by 0
8382 #     P         | String  | pointer to a structure (fixed-length string)
8383 #     p         | String  | pointer to a null-terminated string
8384 # 
8385 #  Misc.        |         |
8386 #  Directive    | Returns | Meaning
8387 #  -----------------------------------------------------------------
8388 #     @         | ---     | skip to the offset given by the length argument
8389 #     X         | ---     | skip backward one byte
8390 #     x         | ---     | skip forward one byte
8391 def unpack(format); []; end
8392 ##
8393 # Returns a complex which denotes the string form.  The parser
8394 # ignores leading whitespaces and trailing garbage.  Any digit
8395 # sequences can be separated by an underscore.  Returns zero for null
8396 # or garbage string.
8397 # 
8398 #    '9'.to_c           #=> (9+0i)
8399 #    '2.5'.to_c         #=> (2.5+0i)
8400 #    '2.5/1'.to_c       #=> ((5/2)+0i)
8401 #    '-3/2'.to_c        #=> ((-3/2)+0i)
8402 #    '-i'.to_c          #=> (0-1i)
8403 #    '45i'.to_c         #=> (0+45i)
8404 #    '3-4i'.to_c        #=> (3-4i)
8405 #    '-4e2-4e-2i'.to_c  #=> (-400.0-0.04i)
8406 #    '-0.0-0.0i'.to_c   #=> (-0.0-0.0i)
8407 #    '1/2+3/4i'.to_c    #=> ((1/2)+(3/4)*i)
8408 #    'ruby'.to_c        #=> (0+0i)
8409 # 
8410 # See Kernel.Complex.
8411 def to_c; Complex.new; end
8412 end
8413 
8414 ##
8415 # <code>Symbol</code> objects represent names and some strings
8416 # inside the Ruby
8417 # interpreter. They are generated using the <code>:name</code> and
8418 # <code>:"string"</code> literals
8419 # syntax, and by the various <code>to_sym</code> methods. The same
8420 # <code>Symbol</code> object will be created for a given name or string
8421 # for the duration of a program's execution, regardless of the context
8422 # or meaning of that name. Thus if <code>Fred</code> is a constant in
8423 # one context, a method in another, and a class in a third, the
8424 # <code>Symbol</code> <code>:Fred</code> will be the same object in
8425 # all three contexts.
8426 # 
8427 #    module One
8428 #      class Fred
8429 #      end
8430 #      $f1 = :Fred
8431 #    end
8432 #    module Two
8433 #      Fred = 1
8434 #      $f2 = :Fred
8435 #    end
8436 #    def Fred()
8437 #    end
8438 #    $f3 = :Fred
8439 #    $f1.object_id   #=> 2514190
8440 #    $f2.object_id   #=> 2514190
8441 #    $f3.object_id   #=> 2514190
8442 class Symbol < Object
8443 include Comparable
8444 ##
8445 # Returns an array of all the symbols currently in Ruby's symbol
8446 # table.
8447 # 
8448 #    Symbol.all_symbols.size    #=> 903
8449 #    Symbol.all_symbols[1,20]   #=> [:floor, :ARGV, :Binding, :symlink,
8450 #                                    :chown, :EOFError, :$;, :String,
8451 #                                    :LOCK_SH, :"setuid?", :$<,
8452 #                                    :default_proc, :compact, :extend,
8453 #                                    :Tms, :getwd, :$=, :ThreadGroup,
8454 #                                    :wait2, :$>]
8455 def self.all_symbols; []; end
8456 ##
8457 # Equality---If <i>sym</i> and <i>obj</i> are exactly the same
8458 # symbol, returns <code>true</code>.
8459 def ==; true || false; end
8460 ##
8461 # Equality---If <i>sym</i> and <i>obj</i> are exactly the same
8462 # symbol, returns <code>true</code>.
8463 def ===; true || false; end
8464 ##
8465 # Returns the representation of <i>sym</i> as a symbol literal.
8466 # 
8467 #    :fred.inspect   #=> ":fred"
8468 def inspect; ''; end
8469 ##
8470 # Returns the name or string corresponding to <i>sym</i>.
8471 # 
8472 #    :fred.id2name   #=> "fred"
8473 def id2name; ''; end
8474 ##
8475 # Returns the name or string corresponding to <i>sym</i>.
8476 # 
8477 #    :fred.id2name   #=> "fred"
8478 def to_s; ''; end
8479 ##
8480 # In general, <code>to_sym</code> returns the <code>Symbol</code> corresponding
8481 # to an object. As <i>sym</i> is already a symbol, <code>self</code> is returned
8482 # in this case.
8483 def to_sym; :a; end
8484 ##
8485 # In general, <code>to_sym</code> returns the <code>Symbol</code> corresponding
8486 # to an object. As <i>sym</i> is already a symbol, <code>self</code> is returned
8487 # in this case.
8488 def intern; :a; end
8489 ##
8490 # Returns a _Proc_ object which respond to the given method by _sym_.
8491 # 
8492 #   (1..3).collect(&:to_s)  #=> ["1", "2", "3"]
8493 def to_proc; end
8494 ##
8495 # Same as <code>sym.to_s.succ.intern</code>.
8496 def succ; end
8497 ##
8498 # Compares +symbol+ with +other_symbol+ after calling #to_s on each of the
8499 # symbols. Returns -1, 0, +1 or nil depending on whether +symbol+ is less
8500 # than, equal to, or greater than +other_symbol+.
8501 # 
8502 #  +nil+ is returned if the two values are incomparable.
8503 # 
8504 # See String#<=> for more information.
8505 def <=>; 1 || nil; end
8506 ##
8507 # Case-insensitive version of <code>Symbol#<=></code>.
8508 def casecmp(other); 1 || nil; end
8509 ##
8510 # Returns <code>sym.to_s =~ obj</code>.
8511 def =~; 1 || nil; end
8512 ##
8513 # Returns <code>sym.to_s[]</code>.
8514 def []; ''; end
8515 ##
8516 # Returns <code>sym.to_s[]</code>.
8517 def slice; ''; end
8518 ##
8519 # Same as <code>sym.to_s.length</code>.
8520 def length; 0; end
8521 ##
8522 # Returns that _sym_ is :"" or not.
8523 def empty?; true || false; end
8524 ##
8525 # Returns <code>sym.to_s =~ obj</code>.
8526 def match; 1 || nil; end
8527 ##
8528 # Same as <code>sym.to_s.upcase.intern</code>.
8529 def upcase; :a; end
8530 ##
8531 # Same as <code>sym.to_s.downcase.intern</code>.
8532 def downcase; :a; end
8533 ##
8534 # Same as <code>sym.to_s.capitalize.intern</code>.
8535 def capitalize; :a; end
8536 ##
8537 # Same as <code>sym.to_s.swapcase.intern</code>.
8538 def swapcase; :a; end
8539 ##
8540 # Returns the Encoding object that represents the encoding of _sym_.
8541 def encoding; Encoding.new; end
8542 end
8543 
8544 ##
8545 # <code>Proc</code> objects are blocks of code that have been bound to
8546 # a set of local variables. Once bound, the code may be called in
8547 # different contexts and still access those variables.
8548 # 
8549 #    def gen_times(factor)
8550 #      return Proc.new {|n| n*factor }
8551 #    end
8552 # 
8553 #    times3 = gen_times(3)
8554 #    times5 = gen_times(5)
8555 # 
8556 #    times3.call(12)               #=> 36
8557 #    times5.call(5)                #=> 25
8558 #    times3.call(times5.call(4))   #=> 60
8559 class Proc < Object
8560 ##
8561 # Creates a new <code>Proc</code> object, bound to the current
8562 # context. <code>Proc::new</code> may be called without a block only
8563 # within a method with an attached block, in which case that block is
8564 # converted to the <code>Proc</code> object.
8565 # 
8566 #    def proc_from
8567 #      Proc.new
8568 #    end
8569 #    proc = proc_from { "hello" }
8570 #    proc.call   #=> "hello"
8571 def self.new(&block); end
8572 ##
8573 # Invokes the block, setting the block's parameters to the values in
8574 # <i>params</i> using something close to method calling semantics.
8575 # Generates a warning if multiple values are passed to a proc that
8576 # expects just one (previously this silently converted the parameters
8577 # to an array).  Note that prc.() invokes prc.call() with the parameters
8578 # given.  It's a syntax sugar to hide "call".
8579 # 
8580 # For procs created using <code>lambda</code> or <code>->()</code> an error
8581 # is generated if the wrong number of parameters are passed to a Proc with
8582 # multiple parameters.  For procs created using <code>Proc.new</code> or
8583 # <code>Kernel.proc</code>, extra parameters are silently discarded.
8584 # 
8585 # Returns the value of the last expression evaluated in the block. See
8586 # also <code>Proc#yield</code>.
8587 # 
8588 #    a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
8589 #    a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
8590 #    a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
8591 #    a_proc = lambda {|a,b| a}
8592 #    a_proc.call(1,2,3)
8593 # 
8594 # <em>produces:</em>
8595 # 
8596 #    prog.rb:4:in `block in <main>': wrong number of arguments (3 for 2) (ArgumentError)
8597 #     from prog.rb:5:in `call'
8598 #     from prog.rb:5:in `<main>'
8599 def call(); Object.new; end
8600 ##
8601 # Invokes the block, setting the block's parameters to the values in
8602 # <i>params</i> using something close to method calling semantics.
8603 # Generates a warning if multiple values are passed to a proc that
8604 # expects just one (previously this silently converted the parameters
8605 # to an array).  Note that prc.() invokes prc.call() with the parameters
8606 # given.  It's a syntax sugar to hide "call".
8607 # 
8608 # For procs created using <code>lambda</code> or <code>->()</code> an error
8609 # is generated if the wrong number of parameters are passed to a Proc with
8610 # multiple parameters.  For procs created using <code>Proc.new</code> or
8611 # <code>Kernel.proc</code>, extra parameters are silently discarded.
8612 # 
8613 # Returns the value of the last expression evaluated in the block. See
8614 # also <code>Proc#yield</code>.
8615 # 
8616 #    a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
8617 #    a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
8618 #    a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
8619 #    a_proc = lambda {|a,b| a}
8620 #    a_proc.call(1,2,3)
8621 # 
8622 # <em>produces:</em>
8623 # 
8624 #    prog.rb:4:in `block in <main>': wrong number of arguments (3 for 2) (ArgumentError)
8625 #     from prog.rb:5:in `call'
8626 #     from prog.rb:5:in `<main>'
8627 def []; Object.new; end
8628 ##
8629 # Invokes the block with +obj+ as the proc's parameter like Proc#call.  It
8630 # is to allow a proc object to be a target of +when+ clause in a case
8631 # statement.
8632 def ===; Proc.new; end
8633 ##
8634 # Invokes the block, setting the block's parameters to the values in
8635 # <i>params</i> using something close to method calling semantics.
8636 # Generates a warning if multiple values are passed to a proc that
8637 # expects just one (previously this silently converted the parameters
8638 # to an array).  Note that prc.() invokes prc.call() with the parameters
8639 # given.  It's a syntax sugar to hide "call".
8640 # 
8641 # For procs created using <code>lambda</code> or <code>->()</code> an error
8642 # is generated if the wrong number of parameters are passed to a Proc with
8643 # multiple parameters.  For procs created using <code>Proc.new</code> or
8644 # <code>Kernel.proc</code>, extra parameters are silently discarded.
8645 # 
8646 # Returns the value of the last expression evaluated in the block. See
8647 # also <code>Proc#yield</code>.
8648 # 
8649 #    a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
8650 #    a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
8651 #    a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
8652 #    a_proc = lambda {|a,b| a}
8653 #    a_proc.call(1,2,3)
8654 # 
8655 # <em>produces:</em>
8656 # 
8657 #    prog.rb:4:in `block in <main>': wrong number of arguments (3 for 2) (ArgumentError)
8658 #     from prog.rb:5:in `call'
8659 #     from prog.rb:5:in `<main>'
8660 def yield(); Object.new; end
8661 ##
8662 # Part of the protocol for converting objects to <code>Proc</code>
8663 # objects. Instances of class <code>Proc</code> simply return
8664 # themselves.
8665 def to_proc; Proc.new; end
8666 ##
8667 # Returns the number of arguments that would not be ignored. If the block
8668 # is declared to take no arguments, returns 0. If the block is known
8669 # to take exactly n arguments, returns n. If the block has optional
8670 # arguments, return -n-1, where n is the number of mandatory
8671 # arguments. A <code>proc</code> with no argument declarations
8672 # is the same a block declaring <code>||</code> as its arguments.
8673 # 
8674 #    proc {}.arity          #=>  0
8675 #    proc {||}.arity        #=>  0
8676 #    proc {|a|}.arity       #=>  1
8677 #    proc {|a,b|}.arity     #=>  2
8678 #    proc {|a,b,c|}.arity   #=>  3
8679 #    proc {|*a|}.arity      #=> -1
8680 #    proc {|a,*b|}.arity    #=> -2
8681 #    proc {|a,*b, c|}.arity #=> -3
8682 # 
8683 #    proc   { |x = 0| }.arity       #=> 0
8684 #    lambda { |a = 0| }.arity       #=> -1
8685 #    proc   { |x=0, y| }.arity      #=> 0
8686 #    lambda { |x=0, y| }.arity      #=> -2
8687 #    proc   { |x=0, y=0| }.arity    #=> 0
8688 #    lambda { |x=0, y=0| }.arity    #=> -1
8689 #    proc   { |x, y=0| }.arity      #=> 1
8690 #    lambda { |x, y=0| }.arity      #=> -2
8691 #    proc   { |(x, y), z=0| }.arity #=> 1
8692 #    lambda { |(x, y), z=0| }.arity #=> -2
8693 def arity; 0; end
8694 ##
8695 # Returns a hash value corresponding to proc body.
8696 def hash; 0; end
8697 ##
8698 # Returns the unique identifier for this proc, along with
8699 # an indication of where the proc was defined.
8700 def to_s; ''; end
8701 ##
8702 # Returns +true+ for a Proc object for which argument handling is rigid.
8703 # Such procs are typically generated by +lambda+.
8704 # 
8705 # A Proc object generated by +proc+ ignores extra arguments.
8706 # 
8707 #   proc {|a,b| [a,b] }.call(1,2,3)    #=> [1,2]
8708 # 
8709 # It provides +nil+ for missing arguments.
8710 # 
8711 #   proc {|a,b| [a,b] }.call(1)        #=> [1,nil]
8712 # 
8713 # It expands a single array argument.
8714 # 
8715 #   proc {|a,b| [a,b] }.call([1,2])    #=> [1,2]
8716 # 
8717 # A Proc object generated by +lambda+ doesn't have such tricks.
8718 # 
8719 #   lambda {|a,b| [a,b] }.call(1,2,3)  #=> ArgumentError
8720 #   lambda {|a,b| [a,b] }.call(1)      #=> ArgumentError
8721 #   lambda {|a,b| [a,b] }.call([1,2])  #=> ArgumentError
8722 # 
8723 # Proc#lambda? is a predicate for the tricks.
8724 # It returns +true+ if no tricks apply.
8725 # 
8726 #   lambda {}.lambda?            #=> true
8727 #   proc {}.lambda?              #=> false
8728 # 
8729 # Proc.new is the same as +proc+.
8730 # 
8731 #   Proc.new {}.lambda?          #=> false
8732 # 
8733 # +lambda+, +proc+ and Proc.new preserve the tricks of
8734 # a Proc object given by <code>&</code> argument.
8735 # 
8736 #   lambda(&lambda {}).lambda?   #=> true
8737 #   proc(&lambda {}).lambda?     #=> true
8738 #   Proc.new(&lambda {}).lambda? #=> true
8739 # 
8740 #   lambda(&proc {}).lambda?     #=> false
8741 #   proc(&proc {}).lambda?       #=> false
8742 #   Proc.new(&proc {}).lambda?   #=> false
8743 # 
8744 # A Proc object generated by <code>&</code> argument has the tricks
8745 # 
8746 #   def n(&b) b.lambda? end
8747 #   n {}                         #=> false
8748 # 
8749 # The <code>&</code> argument preserves the tricks if a Proc object
8750 # is given by <code>&</code> argument.
8751 # 
8752 #   n(&lambda {})                #=> true
8753 #   n(&proc {})                  #=> false
8754 #   n(&Proc.new {})              #=> false
8755 # 
8756 # A Proc object converted from a method has no tricks.
8757 # 
8758 #   def m() end
8759 #   method(:m).to_proc.lambda?   #=> true
8760 # 
8761 #   n(&method(:m))               #=> true
8762 #   n(&method(:m).to_proc)       #=> true
8763 # 
8764 # +define_method+ is treated the same as method definition.
8765 # The defined method has no tricks.
8766 # 
8767 #   class C
8768 #     define_method(:d) {}
8769 #   end
8770 #   C.new.d(1,2)       #=> ArgumentError
8771 #   C.new.method(:d).to_proc.lambda?   #=> true
8772 # 
8773 # +define_method+ always defines a method without the tricks,
8774 # even if a non-lambda Proc object is given.
8775 # This is the only exception for which the tricks are not preserved.
8776 # 
8777 #   class C
8778 #     define_method(:e, &proc {})
8779 #   end
8780 #   C.new.e(1,2)       #=> ArgumentError
8781 #   C.new.method(:e).to_proc.lambda?   #=> true
8782 # 
8783 # This exception insures that methods never have tricks
8784 # and makes it easy to have wrappers to define methods that behave as usual.
8785 # 
8786 #   class C
8787 #     def self.def2(name, &body)
8788 #       define_method(name, &body)
8789 #     end
8790 # 
8791 #     def2(:f) {}
8792 #   end
8793 #   C.new.f(1,2)       #=> ArgumentError
8794 # 
8795 # The wrapper <i>def2</i> defines a method which has no tricks.
8796 def lambda?; true || false; end
8797 ##
8798 # Returns the binding associated with <i>prc</i>. Note that
8799 # <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
8800 # <code>Binding</code> object as its second parameter.
8801 # 
8802 #    def fred(param)
8803 #      proc {}
8804 #    end
8805 # 
8806 #    b = fred(99)
8807 #    eval("param", b.binding)   #=> 99
8808 def binding; Binding.new; end
8809 ##
8810 # Returns a curried proc. If the optional <i>arity</i> argument is given,
8811 # it determines the number of arguments.
8812 # A curried proc receives some arguments. If a sufficient number of
8813 # arguments are supplied, it passes the supplied arguments to the original
8814 # proc and returns the result. Otherwise, returns another curried proc that
8815 # takes the rest of arguments.
8816 # 
8817 #    b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
8818 #    p b.curry[1][2][3]           #=> 6
8819 #    p b.curry[1, 2][3, 4]        #=> 6
8820 #    p b.curry(5)[1][2][3][4][5]  #=> 6
8821 #    p b.curry(5)[1, 2][3, 4][5]  #=> 6
8822 #    p b.curry(1)[1]              #=> 1
8823 # 
8824 #    b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) }
8825 #    p b.curry[1][2][3]           #=> 6
8826 #    p b.curry[1, 2][3, 4]        #=> 10
8827 #    p b.curry(5)[1][2][3][4][5]  #=> 15
8828 #    p b.curry(5)[1, 2][3, 4][5]  #=> 15
8829 #    p b.curry(1)[1]              #=> 1
8830 # 
8831 #    b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) }
8832 #    p b.curry[1][2][3]           #=> 6
8833 #    p b.curry[1, 2][3, 4]        #=> wrong number of arguments (4 for 3)
8834 #    p b.curry(5)                 #=> wrong number of arguments (5 for 3)
8835 #    p b.curry(1)                 #=> wrong number of arguments (1 for 3)
8836 # 
8837 #    b = lambda {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) }
8838 #    p b.curry[1][2][3]           #=> 6
8839 #    p b.curry[1, 2][3, 4]        #=> 10
8840 #    p b.curry(5)[1][2][3][4][5]  #=> 15
8841 #    p b.curry(5)[1, 2][3, 4][5]  #=> 15
8842 #    p b.curry(1)                 #=> wrong number of arguments (1 for 3)
8843 # 
8844 #    b = proc { :foo }
8845 #    p b.curry[]                  #=> :foo
8846 def curry; Proc.new; end
8847 ##
8848 # Returns the Ruby source filename and line number containing this proc
8849 # or +nil+ if this proc was not defined in Ruby (i.e. native)
8850 def source_location; ['', 0]; end
8851 ##
8852 # Returns the parameter information of this proc.
8853 # 
8854 #    prc = lambda{|x, y=42, *other|}
8855 #    prc.parameters  #=> [[:req, :x], [:opt, :y], [:rest, :other]]
8856 def parameters; []; end
8857 end
8858 
8859 ##
8860 # Raised when Ruby can't yield as requested.
8861 # 
8862 # A typical scenario is attempting to yield when no block is given:
8863 # 
8864 #    def call_block
8865 #      yield 42
8866 #    end
8867 #    call_block
8868 # 
8869 # <em>raises the exception:</em>
8870 # 
8871 #    LocalJumpError: no block given (yield)
8872 # 
8873 # A more subtle example:
8874 # 
8875 #    def get_me_a_return
8876 #      Proc.new { return 42 }
8877 #    end
8878 #    get_me_a_return.call
8879 # 
8880 # <em>raises the exception:</em>
8881 # 
8882 #    LocalJumpError: unexpected return
8883 class LocalJumpError < StandardError
8884 ##
8885 # The reason this block was terminated:
8886 # :break, :redo, :retry, :next, :return, or :noreason.
8887 def reason; :a; end
8888 end
8889 
8890 ##
8891 # Raised in case of a stack overflow.
8892 # 
8893 #    def me_myself_and_i
8894 #      me_myself_and_i
8895 #    end
8896 #    me_myself_and_i
8897 # 
8898 # <em>raises the exception:</em>
8899 # 
8900 #   SystemStackError: stack level too deep
8901 class SystemStackError < Exception
8902 end
8903 
8904 ##
8905 # Proc   
8906 class Method < Object
8907 ##
8908 # Two method objects are equal if they are bound to the same
8909 # object and refer to the same method definition and their owners are the
8910 # same class or module.
8911 def ==; true || false; end
8912 ##
8913 # Two method objects are equal if they are bound to the same
8914 # object and refer to the same method definition and their owners are the
8915 # same class or module.
8916 def eql?; true || false; end
8917 ##
8918 # Returns a hash value corresponding to the method object.
8919 def hash; 0; end
8920 ##
8921 # Returns a clone of this method.
8922 # 
8923 #   class A
8924 #     def foo
8925 #       return "bar"
8926 #     end
8927 #   end
8928 # 
8929 #   m = A.new.method(:foo)
8930 #   m.call # => "bar"
8931 #   n = m.clone.call # => "bar"
8932 def clone; Method.new; end
8933 ##
8934 # Invokes the <i>meth</i> with the specified arguments, returning the
8935 # method's return value.
8936 # 
8937 #    m = 12.method("+")
8938 #    m.call(3)    #=> 15
8939 #    m.call(20)   #=> 32
8940 def call(); Object.new; end
8941 ##
8942 # Invokes the <i>meth</i> with the specified arguments, returning the
8943 # method's return value.
8944 # 
8945 #    m = 12.method("+")
8946 #    m.call(3)    #=> 15
8947 #    m.call(20)   #=> 32
8948 def []; Object.new; end
8949 ##
8950 # Returns an indication of the number of arguments accepted by a
8951 # method. Returns a nonnegative integer for methods that take a fixed
8952 # number of arguments. For Ruby methods that take a variable number of
8953 # arguments, returns -n-1, where n is the number of required
8954 # arguments. For methods written in C, returns -1 if the call takes a
8955 # variable number of arguments.
8956 # 
8957 #    class C
8958 #      def one;    end
8959 #      def two(a); end
8960 #      def three(*a);  end
8961 #      def four(a, b); end
8962 #      def five(a, b, *c);    end
8963 #      def six(a, b, *c, &d); end
8964 #    end
8965 #    c = C.new
8966 #    c.method(:one).arity     #=> 0
8967 #    c.method(:two).arity     #=> 1
8968 #    c.method(:three).arity   #=> -1
8969 #    c.method(:four).arity    #=> 2
8970 #    c.method(:five).arity    #=> -3
8971 #    c.method(:six).arity     #=> -3
8972 # 
8973 #    "cat".method(:size).arity      #=> 0
8974 #    "cat".method(:replace).arity   #=> 1
8975 #    "cat".method(:squeeze).arity   #=> -1
8976 #    "cat".method(:count).arity     #=> -1
8977 def arity; 0; end
8978 ##
8979 # Returns the name of the underlying method.
8980 # 
8981 #   "cat".method(:count).inspect   #=> "#<Method: String#count>"
8982 def to_s; ''; end
8983 ##
8984 # Returns the name of the underlying method.
8985 # 
8986 #   "cat".method(:count).inspect   #=> "#<Method: String#count>"
8987 def inspect; ''; end
8988 ##
8989 # Returns a <code>Proc</code> object corresponding to this method.
8990 def to_proc; Proc.new; end
8991 ##
8992 # Returns the bound receiver of the method object.
8993 def receiver; Object.new; end
8994 ##
8995 # Returns the name of the method.
8996 def name; :a; end
8997 ##
8998 # Returns the original name of the method.
8999 def original_name; :a; end
9000 ##
9001 # Returns the class or module that defines the method.
9002 def owner; Class.new || Module.new; end
9003 ##
9004 # Dissociates <i>meth</i> from its current receiver. The resulting
9005 # <code>UnboundMethod</code> can subsequently be bound to a new object
9006 # of the same class (see <code>UnboundMethod</code>).
9007 def unbind; Method.new; end
9008 ##
9009 # Returns the Ruby source filename and line number containing this method
9010 # or nil if this method was not defined in Ruby (i.e. native)
9011 def source_location; ['', 0]; end
9012 ##
9013 # Returns the parameter information of this method.
9014 def parameters; []; end
9015 end
9016 
9017 ##
9018 # Ruby supports two forms of objectified methods. Class
9019 # <code>Method</code> is used to represent methods that are associated
9020 # with a particular object: these method objects are bound to that
9021 # object. Bound method objects for an object can be created using
9022 # <code>Object#method</code>.
9023 # 
9024 # Ruby also supports unbound methods; methods objects that are not
9025 # associated with a particular object. These can be created either by
9026 # calling <code>Module#instance_method</code> or by calling
9027 # <code>unbind</code> on a bound method object. The result of both of
9028 # these is an <code>UnboundMethod</code> object.
9029 # 
9030 # Unbound methods can only be called after they are bound to an
9031 # object. That object must be be a kind_of? the method's original
9032 # class.
9033 # 
9034 #    class Square
9035 #      def area
9036 #        @side * @side
9037 #      end
9038 #      def initialize(side)
9039 #        @side = side
9040 #      end
9041 #    end
9042 # 
9043 #    area_un = Square.instance_method(:area)
9044 # 
9045 #    s = Square.new(12)
9046 #    area = area_un.bind(s)
9047 #    area.call   #=> 144
9048 # 
9049 # Unbound methods are a reference to the method at the time it was
9050 # objectified: subsequent changes to the underlying class will not
9051 # affect the unbound method.
9052 # 
9053 #    class Test
9054 #      def test
9055 #        :original
9056 #      end
9057 #    end
9058 #    um = Test.instance_method(:test)
9059 #    class Test
9060 #      def test
9061 #        :modified
9062 #      end
9063 #    end
9064 #    t = Test.new
9065 #    t.test            #=> :modified
9066 #    um.bind(t).call   #=> :original
9067 class UnboundMethod < Object
9068 ##
9069 # Two method objects are equal if they are bound to the same
9070 # object and refer to the same method definition and their owners are the
9071 # same class or module.
9072 def ==; true || false; end
9073 ##
9074 # Two method objects are equal if they are bound to the same
9075 # object and refer to the same method definition and their owners are the
9076 # same class or module.
9077 def eql?; true || false; end
9078 ##
9079 # Returns a hash value corresponding to the method object.
9080 def hash; 0; end
9081 ##
9082 # Returns a clone of this method.
9083 # 
9084 #   class A
9085 #     def foo
9086 #       return "bar"
9087 #     end
9088 #   end
9089 # 
9090 #   m = A.new.method(:foo)
9091 #   m.call # => "bar"
9092 #   n = m.clone.call # => "bar"
9093 def clone; Method.new; end
9094 ##
9095 # Returns an indication of the number of arguments accepted by a
9096 # method. Returns a nonnegative integer for methods that take a fixed
9097 # number of arguments. For Ruby methods that take a variable number of
9098 # arguments, returns -n-1, where n is the number of required
9099 # arguments. For methods written in C, returns -1 if the call takes a
9100 # variable number of arguments.
9101 # 
9102 #    class C
9103 #      def one;    end
9104 #      def two(a); end
9105 #      def three(*a);  end
9106 #      def four(a, b); end
9107 #      def five(a, b, *c);    end
9108 #      def six(a, b, *c, &d); end
9109 #    end
9110 #    c = C.new
9111 #    c.method(:one).arity     #=> 0
9112 #    c.method(:two).arity     #=> 1
9113 #    c.method(:three).arity   #=> -1
9114 #    c.method(:four).arity    #=> 2
9115 #    c.method(:five).arity    #=> -3
9116 #    c.method(:six).arity     #=> -3
9117 # 
9118 #    "cat".method(:size).arity      #=> 0
9119 #    "cat".method(:replace).arity   #=> 1
9120 #    "cat".method(:squeeze).arity   #=> -1
9121 #    "cat".method(:count).arity     #=> -1
9122 def arity; 0; end
9123 ##
9124 # Returns the name of the underlying method.
9125 # 
9126 #   "cat".method(:count).inspect   #=> "#<Method: String#count>"
9127 def to_s; ''; end
9128 ##
9129 # Returns the name of the underlying method.
9130 # 
9131 #   "cat".method(:count).inspect   #=> "#<Method: String#count>"
9132 def inspect; ''; end
9133 ##
9134 # Returns the name of the method.
9135 def name; :a; end
9136 ##
9137 # Returns the original name of the method.
9138 def original_name; :a; end
9139 ##
9140 # Returns the class or module that defines the method.
9141 def owner; Class.new || Module.new; end
9142 ##
9143 # Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
9144 # from which <i>umeth</i> was obtained,
9145 # <code>obj.kind_of?(Klass)</code> must be true.
9146 # 
9147 #    class A
9148 #      def test
9149 #        puts "In test, class = #{self.class}"
9150 #      end
9151 #    end
9152 #    class B < A
9153 #    end
9154 #    class C < B
9155 #    end
9156 # 
9157 #    um = B.instance_method(:test)
9158 #    bm = um.bind(C.new)
9159 #    bm.call
9160 #    bm = um.bind(B.new)
9161 #    bm.call
9162 #    bm = um.bind(A.new)
9163 #    bm.call
9164 # 
9165 # <em>produces:</em>
9166 # 
9167 #    In test, class = C
9168 #    In test, class = B
9169 #    prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
9170 #     from prog.rb:16
9171 def bind(obj); Method.new; end
9172 ##
9173 # Returns the Ruby source filename and line number containing this method
9174 # or nil if this method was not defined in Ruby (i.e. native)
9175 def source_location; ['', 0]; end
9176 ##
9177 # Returns the parameter information of this method.
9178 def parameters; []; end
9179 end
9180 
9181 ##
9182 # Objects of class <code>Binding</code> encapsulate the execution
9183 # context at some particular place in the code and retain this context
9184 # for future use. The variables, methods, value of <code>self</code>,
9185 # and possibly an iterator block that can be accessed in this context
9186 # are all retained. Binding objects can be created using
9187 # <code>Kernel#binding</code>, and are made available to the callback
9188 # of <code>Kernel#set_trace_func</code>.
9189 # 
9190 # These binding objects can be passed as the second argument of the
9191 # <code>Kernel#eval</code> method, establishing an environment for the
9192 # evaluation.
9193 # 
9194 #    class Demo
9195 #      def initialize(n)
9196 #        @secret = n
9197 #      end
9198 #      def get_binding
9199 #        return binding()
9200 #      end
9201 #    end
9202 # 
9203 #    k1 = Demo.new(99)
9204 #    b1 = k1.get_binding
9205 #    k2 = Demo.new(-3)
9206 #    b2 = k2.get_binding
9207 # 
9208 #    eval("@secret", b1)   #=> 99
9209 #    eval("@secret", b2)   #=> -3
9210 #    eval("@secret")       #=> nil
9211 # 
9212 # Binding objects have no class-specific methods.
9213 class Binding < Object
9214 ##
9215 # Evaluates the Ruby expression(s) in <em>string</em>, in the
9216 # <em>binding</em>'s context.  If the optional <em>filename</em> and
9217 # <em>lineno</em> parameters are present, they will be used when
9218 # reporting syntax errors.
9219 # 
9220 #    def get_binding(param)
9221 #      return binding
9222 #    end
9223 #    b = get_binding("hello")
9224 #    b.eval("param")   #=> "hello"
9225 def eval(string , filename=0, lineno=0); Object.new; end
9226 end
9227 
9228 class Module < Object
9229 ##
9230 # Returns an +UnboundMethod+ representing the given
9231 # instance method in _mod_.
9232 # 
9233 #    class Interpreter
9234 #      def do_a() print "there, "; end
9235 #      def do_d() print "Hello ";  end
9236 #      def do_e() print "!\n";     end
9237 #      def do_v() print "Dave";    end
9238 #      Dispatcher = {
9239 #        "a" => instance_method(:do_a),
9240 #        "d" => instance_method(:do_d),
9241 #        "e" => instance_method(:do_e),
9242 #        "v" => instance_method(:do_v)
9243 #      }
9244 #      def interpret(string)
9245 #        string.each_char {|b| Dispatcher[b].bind(self).call }
9246 #      end
9247 #    end
9248 # 
9249 #    interpreter = Interpreter.new
9250 #    interpreter.interpret('dave')
9251 # 
9252 # <em>produces:</em>
9253 # 
9254 #    Hello there, Dave!
9255 def instance_method(symbol); Method.new; end
9256 ##
9257 # Similar to _instance_method_, searches public method only.
9258 def public_instance_method(symbol); Method.new; end
9259 ##
9260 # Defines an instance method in the receiver. The _method_
9261 # parameter can be a +Proc+, a +Method+ or an +UnboundMethod+ object.
9262 # If a block is specified, it is used as the method body. This block
9263 # is evaluated using <code>instance_eval</code>, a point that is
9264 # tricky to demonstrate because <code>define_method</code> is private.
9265 # (This is why we resort to the +send+ hack in this example.)
9266 # 
9267 #    class A
9268 #      def fred
9269 #        puts "In Fred"
9270 #      end
9271 #      def create_method(name, &block)
9272 #        self.class.send(:define_method, name, &block)
9273 #      end
9274 #      define_method(:wilma) { puts "Charge it!" }
9275 #    end
9276 #    class B < A
9277 #      define_method(:barney, instance_method(:fred))
9278 #    end
9279 #    a = B.new
9280 #    a.barney
9281 #    a.wilma
9282 #    a.create_method(:betty) { p self }
9283 #    a.betty
9284 # 
9285 # <em>produces:</em>
9286 # 
9287 #    In Fred
9288 #    Charge it!
9289 #    #<B:0x401b39e8>
9290 def define_method(symbol, method); Proc.new; end
9291 ##
9292 # Evaluates the given block in the context of the class/module.
9293 # The method defined in the block will belong to the receiver.
9294 # 
9295 #    class Thing
9296 #    end
9297 #    Thing.class_exec{
9298 #      def hello() "Hello there!" end
9299 #    }
9300 #    puts Thing.new.hello()
9301 # 
9302 # <em>produces:</em>
9303 # 
9304 #    Hello there!
9305 def module_exec(&block); Object.new; end
9306 ##
9307 # Evaluates the given block in the context of the class/module.
9308 # The method defined in the block will belong to the receiver.
9309 # 
9310 #    class Thing
9311 #    end
9312 #    Thing.class_exec{
9313 #      def hello() "Hello there!" end
9314 #    }
9315 #    puts Thing.new.hello()
9316 # 
9317 # <em>produces:</em>
9318 # 
9319 #    Hello there!
9320 def class_exec(&block); Object.new; end
9321 ##
9322 # Evaluates the string or block in the context of _mod_, except that when
9323 # a block is given, constant/class variable lookup is not affected. This
9324 # can be used to add methods to a class. <code>module_eval</code> returns
9325 # the result of evaluating its argument. The optional _filename_ and
9326 # _lineno_ parameters set the text for error messages.
9327 # 
9328 #    class Thing
9329 #    end
9330 #    a = %q{def hello() "Hello there!" end}
9331 #    Thing.module_eval(a)
9332 #    puts Thing.new.hello()
9333 #    Thing.module_eval("invalid code", "dummy", 123)
9334 # 
9335 # <em>produces:</em>
9336 # 
9337 #    Hello there!
9338 #    dummy:123:in `module_eval': undefined local variable
9339 #        or method `code' for Thing:Class
9340 def class_eval(string , filename=0, lineno=0); Object.new; end
9341 ##
9342 # Evaluates the string or block in the context of _mod_, except that when
9343 # a block is given, constant/class variable lookup is not affected. This
9344 # can be used to add methods to a class. <code>module_eval</code> returns
9345 # the result of evaluating its argument. The optional _filename_ and
9346 # _lineno_ parameters set the text for error messages.
9347 # 
9348 #    class Thing
9349 #    end
9350 #    a = %q{def hello() "Hello there!" end}
9351 #    Thing.module_eval(a)
9352 #    puts Thing.new.hello()
9353 #    Thing.module_eval("invalid code", "dummy", 123)
9354 # 
9355 # <em>produces:</em>
9356 # 
9357 #    Hello there!
9358 #    dummy:123:in `module_eval': undefined local variable
9359 #        or method `code' for Thing:Class
9360 def module_eval(&block); Object.new; end
9361 ##
9362 # When this module is included in another, Ruby calls
9363 # <code>append_features</code> in this module, passing it the
9364 # receiving module in _mod_. Ruby's default implementation is
9365 # to add the constants, methods, and module variables of this module
9366 # to _mod_ if this module has not already been added to
9367 # _mod_ or one of its ancestors. See also <code>Module#include</code>.
9368 def append_features(mod); Module.new; end
9369 ##
9370 # Extends the specified object by adding this module's constants and
9371 # methods (which are added as singleton methods). This is the callback
9372 # method used by <code>Object#extend</code>.
9373 # 
9374 #    module Picky
9375 #      def Picky.extend_object(o)
9376 #        if String === o
9377 #          puts "Can't add Picky to a String"
9378 #        else
9379 #          puts "Picky added to #{o.class}"
9380 #          super
9381 #        end
9382 #      end
9383 #    end
9384 #    (s = Array.new).extend Picky  # Call Object.extend
9385 #    (s = "quick brown fox").extend Picky
9386 # 
9387 # <em>produces:</em>
9388 # 
9389 #    Picky added to Array
9390 #    Can't add Picky to a String
9391 def extend_object(obj); Object.new; end
9392 ##
9393 # Invokes <code>Module.append_features</code> on each parameter in reverse order.
9394 def include(); self; end
9395 ##
9396 # When this module is prepended in another, Ruby calls
9397 # <code>prepend_features</code> in this module, passing it the
9398 # receiving module in _mod_. Ruby's default implementation is
9399 # to overlay the constants, methods, and module variables of this module
9400 # to _mod_ if this module has not already been added to
9401 # _mod_ or one of its ancestors. See also <code>Module#prepend</code>.
9402 def prepend_features(mod); Module.new; end
9403 ##
9404 # Invokes <code>Module.prepend_features</code> on each parameter in reverse order.
9405 def prepend(); self; end
9406 ##
9407 # Refine <i>klass</i> in the receiver.
9408 # 
9409 # Returns an overlaid module.
9410 def refine(klass, &block); Module.new; end
9411 ##
9412 # Returns the list of +Modules+ nested at the point of call.
9413 # 
9414 #    module M1
9415 #      module M2
9416 #        $a = Module.nesting
9417 #      end
9418 #    end
9419 #    $a           #=> [M1::M2, M1]
9420 #    $a[0].name   #=> "M1::M2"
9421 def self.nesting; []; end
9422 ##
9423 # In the first form, returns an array of the names of all
9424 # constants accessible from the point of call.
9425 # This list includes the names of all modules and classes
9426 # defined in the global scope.
9427 # 
9428 #    Module.constants.first(4)
9429 #       # => [:ARGF, :ARGV, :ArgumentError, :Array]
9430 # 
9431 #    Module.constants.include?(:SEEK_SET)   # => false
9432 # 
9433 #    class IO
9434 #      Module.constants.include?(:SEEK_SET) # => true
9435 #    end
9436 # 
9437 # The second form calls the instance method +constants+.
9438 def self.constants(inherit=true); []; end
9439 ##
9440 # Removes the method identified by _symbol_ from the current
9441 # class. For an example, see <code>Module.undef_method</code>.
9442 # String arguments are converted to symbols.
9443 def remove_method(symbol); self; end
9444 ##
9445 # Prevents the current class from responding to calls to the named
9446 # method. Contrast this with <code>remove_method</code>, which deletes
9447 # the method from the particular class; Ruby will still search
9448 # superclasses and mixed-in modules for a possible receiver.
9449 # String arguments are converted to symbols.
9450 # 
9451 #    class Parent
9452 #      def hello
9453 #        puts "In parent"
9454 #      end
9455 #    end
9456 #    class Child < Parent
9457 #      def hello
9458 #        puts "In child"
9459 #      end
9460 #    end
9461 # 
9462 #    c = Child.new
9463 #    c.hello
9464 # 
9465 #    class Child
9466 #      remove_method :hello  # remove from child, still in parent
9467 #    end
9468 #    c.hello
9469 # 
9470 #    class Child
9471 #      undef_method :hello   # prevent any calls to 'hello'
9472 #    end
9473 #    c.hello
9474 # 
9475 # <em>produces:</em>
9476 # 
9477 #    In child
9478 #    In parent
9479 #    prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
9480 def undef_method(symbol); self; end
9481 ##
9482 # Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
9483 # be used to retain access to methods that are overridden.
9484 # 
9485 #    module Mod
9486 #      alias_method :orig_exit, :exit
9487 #      def exit(code=0)
9488 #        puts "Exiting with code #{code}"
9489 #        orig_exit(code)
9490 #      end
9491 #    end
9492 #    include Mod
9493 #    exit(99)
9494 # 
9495 # <em>produces:</em>
9496 # 
9497 #    Exiting with code 99
9498 def alias_method(new_name, old_name); self; end
9499 ##
9500 # With no arguments, sets the default visibility for subsequently
9501 # defined methods to public. With arguments, sets the named methods to
9502 # have public visibility.
9503 # String arguments are converted to symbols.
9504 def public; self; end
9505 ##
9506 # With no arguments, sets the default visibility for subsequently
9507 # defined methods to protected. With arguments, sets the named methods
9508 # to have protected visibility.
9509 # String arguments are converted to symbols.
9510 def protected; self; end
9511 ##
9512 # With no arguments, sets the default visibility for subsequently
9513 # defined methods to private. With arguments, sets the named methods
9514 # to have private visibility.
9515 # String arguments are converted to symbols.
9516 # 
9517 #    module Mod
9518 #      def a()  end
9519 #      def b()  end
9520 #      private
9521 #      def c()  end
9522 #      private :a
9523 #    end
9524 #    Mod.private_instance_methods   #=> [:a, :c]
9525 def private; self; end
9526 ##
9527 # Creates module functions for the named methods. These functions may
9528 # be called with the module as a receiver, and also become available
9529 # as instance methods to classes that mix in the module. Module
9530 # functions are copies of the original, and so may be changed
9531 # independently. The instance-method versions are made private. If
9532 # used with no arguments, subsequently defined methods become module
9533 # functions.
9534 # String arguments are converted to symbols.
9535 # 
9536 #    module Mod
9537 #      def one
9538 #        "This is one"
9539 #      end
9540 #      module_function :one
9541 #    end
9542 #    class Cls
9543 #      include Mod
9544 #      def call_one
9545 #        one
9546 #      end
9547 #    end
9548 #    Mod.one     #=> "This is one"
9549 #    c = Cls.new
9550 #    c.call_one  #=> "This is one"
9551 #    module Mod
9552 #      def one
9553 #        "This is the new one"
9554 #      end
9555 #    end
9556 #    Mod.one     #=> "This is one"
9557 #    c.call_one  #=> "This is the new one"
9558 def module_function(); self; end
9559 ##
9560 # Returns +true+ if the named method is defined by
9561 # _mod_ (or its included modules and, if _mod_ is a class,
9562 # its ancestors). Public and protected methods are matched.
9563 # String arguments are converted to symbols.
9564 # 
9565 #    module A
9566 #      def method1()  end
9567 #    end
9568 #    class B
9569 #      def method2()  end
9570 #    end
9571 #    class C < B
9572 #      include A
9573 #      def method3()  end
9574 #    end
9575 # 
9576 #    A.method_defined? :method1    #=> true
9577 #    C.method_defined? "method1"   #=> true
9578 #    C.method_defined? "method2"   #=> true
9579 #    C.method_defined? "method3"   #=> true
9580 #    C.method_defined? "method4"   #=> false
9581 def method_defined?(symbol); true || false; end
9582 ##
9583 # Returns +true+ if the named public method is defined by
9584 # _mod_ (or its included modules and, if _mod_ is a class,
9585 # its ancestors).
9586 # String arguments are converted to symbols.
9587 # 
9588 #    module A
9589 #      def method1()  end
9590 #    end
9591 #    class B
9592 #      protected
9593 #      def method2()  end
9594 #    end
9595 #    class C < B
9596 #      include A
9597 #      def method3()  end
9598 #    end
9599 # 
9600 #    A.method_defined? :method1           #=> true
9601 #    C.public_method_defined? "method1"   #=> true
9602 #    C.public_method_defined? "method2"   #=> false
9603 #    C.method_defined? "method2"          #=> true
9604 def public_method_defined?(symbol); true || false; end
9605 ##
9606 # Returns +true+ if the named private method is defined by
9607 # _ mod_ (or its included modules and, if _mod_ is a class,
9608 # its ancestors).
9609 # String arguments are converted to symbols.
9610 # 
9611 #    module A
9612 #      def method1()  end
9613 #    end
9614 #    class B
9615 #      private
9616 #      def method2()  end
9617 #    end
9618 #    class C < B
9619 #      include A
9620 #      def method3()  end
9621 #    end
9622 # 
9623 #    A.method_defined? :method1            #=> true
9624 #    C.private_method_defined? "method1"   #=> false
9625 #    C.private_method_defined? "method2"   #=> true
9626 #    C.method_defined? "method2"           #=> false
9627 def private_method_defined?(symbol); true || false; end
9628 ##
9629 # Returns +true+ if the named protected method is defined
9630 # by _mod_ (or its included modules and, if _mod_ is a
9631 # class, its ancestors).
9632 # String arguments are converted to symbols.
9633 # 
9634 #    module A
9635 #      def method1()  end
9636 #    end
9637 #    class B
9638 #      protected
9639 #      def method2()  end
9640 #    end
9641 #    class C < B
9642 #      include A
9643 #      def method3()  end
9644 #    end
9645 # 
9646 #    A.method_defined? :method1              #=> true
9647 #    C.protected_method_defined? "method1"   #=> false
9648 #    C.protected_method_defined? "method2"   #=> true
9649 #    C.method_defined? "method2"             #=> true
9650 def protected_method_defined?(symbol); true || false; end
9651 ##
9652 # Makes a list of existing class methods public.
9653 # 
9654 # String arguments are converted to symbols.
9655 def public_class_method(); Module.new; end
9656 ##
9657 # Makes existing class methods private. Often used to hide the default
9658 # constructor <code>new</code>.
9659 # 
9660 # String arguments are converted to symbols.
9661 # 
9662 #    class SimpleSingleton  # Not thread safe
9663 #      private_class_method :new
9664 #      def SimpleSingleton.create(*args, &block)
9665 #        @me = new(*args, &block) if ! @me
9666 #        @me
9667 #      end
9668 #    end
9669 def private_class_method(); Module.new; end
9670 ##
9671 # Registers _filename_ to be loaded (using <code>Kernel::require</code>)
9672 # the first time that _module_ (which may be a <code>String</code> or
9673 # a symbol) is accessed in the namespace of _mod_.
9674 # 
9675 #    module A
9676 #    end
9677 #    A.autoload(:B, "b")
9678 #    A::B.doit            # autoloads "b"
9679 def autoload(modul, filename); end
9680 ##
9681 # Returns _filename_ to be loaded if _name_ is registered as
9682 # +autoload+ in the namespace of _mod_.
9683 # 
9684 #    module A
9685 #    end
9686 #    A.autoload(:B, "b")
9687 #    A.autoload?(:B)            #=> "b"
9688 def autoload?(name); '' || nil; end
9689 ##
9690 # Callback invoked whenever the receiver is included in another
9691 # module or class. This should be used in preference to
9692 # <tt>Module.append_features</tt> if your code wants to perform some
9693 # action when a module is included in another.
9694 # 
9695 #        module A
9696 #          def A.included(mod)
9697 #            puts "#{self} included in #{mod}"
9698 #          end
9699 #        end
9700 #        module Enumerable
9701 #          include A
9702 #        end
9703 #         # => prints "A included in Enumerable"
9704 def included( othermod ); end
9705 ##
9706 # The equivalent of <tt>included</tt>, but for prepended modules.
9707 # 
9708 #        module A
9709 #          def self.prepended(mod)
9710 #            puts "#{self} prepended to #{mod}"
9711 #          end
9712 #        end
9713 #        module Enumerable
9714 #          prepend A
9715 #        end
9716 #         # => prints "A prepended to Enumerable"
9717 def prepended( othermod ); end
9718 ##
9719 # Invoked as a callback whenever an instance method is added to the
9720 # receiver.
9721 # 
9722 #   module Chatty
9723 #     def self.method_added(method_name)
9724 #       puts "Adding #{method_name.inspect}"
9725 #     end
9726 #     def self.some_class_method() end
9727 #     def some_instance_method() end
9728 #   end
9729 # 
9730 # produces:
9731 # 
9732 #   Adding :some_instance_method
9733 def method_added(method_name); end
9734 ##
9735 # Invoked as a callback whenever an instance method is removed from the
9736 # receiver.
9737 # 
9738 #   module Chatty
9739 #     def self.method_removed(method_name)
9740 #       puts "Removing #{method_name.inspect}"
9741 #     end
9742 #     def self.some_class_method() end
9743 #     def some_instance_method() end
9744 #     class << self
9745 #       remove_method :some_class_method
9746 #     end
9747 #     remove_method :some_instance_method
9748 #   end
9749 # 
9750 # produces:
9751 # 
9752 #   Removing :some_instance_method
9753 def method_removed(method_name); end
9754 ##
9755 # Prevents further modifications to <i>mod</i>.
9756 # 
9757 # This method returns self.
9758 def freeze; Module.new; end
9759 ##
9760 # Case Equality---Returns <code>true</code> if <i>anObject</i> is an
9761 # instance of <i>mod</i> or one of <i>mod</i>'s descendants. Of
9762 # limited use for modules, but can be used in <code>case</code>
9763 # statements to classify objects by class.
9764 def ===; true || false; end
9765 ##
9766 # Equality --- At the <code>Object</code> level, <code>==</code> returns
9767 # <code>true</code> only if +obj+ and +other+ are the same object.
9768 # Typically, this method is overridden in descendant classes to provide
9769 # class-specific meaning.
9770 # 
9771 # Unlike <code>==</code>, the <code>equal?</code> method should never be
9772 # overridden by subclasses as it is used to determine object identity
9773 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
9774 # same object as <code>b</code>):
9775 # 
9776 #   obj = "a"
9777 #   other = obj.dup
9778 # 
9779 #   a == other      #=> true
9780 #   a.equal? other  #=> false
9781 #   a.equal? a      #=> true
9782 # 
9783 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
9784 # +other+ refer to the same hash key.  This is used by Hash to test members
9785 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
9786 # is synonymous with <code>==</code>.  Subclasses normally continue this
9787 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
9788 # method, but there are exceptions.  <code>Numeric</code> types, for
9789 # example, perform type conversion across <code>==</code>, but not across
9790 # <code>eql?</code>, so:
9791 # 
9792 #    1 == 1.0     #=> true
9793 #    1.eql? 1.0   #=> false
9794 def ==; true || false; end
9795 ##
9796 # Equality --- At the <code>Object</code> level, <code>==</code> returns
9797 # <code>true</code> only if +obj+ and +other+ are the same object.
9798 # Typically, this method is overridden in descendant classes to provide
9799 # class-specific meaning.
9800 # 
9801 # Unlike <code>==</code>, the <code>equal?</code> method should never be
9802 # overridden by subclasses as it is used to determine object identity
9803 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
9804 # same object as <code>b</code>):
9805 # 
9806 #   obj = "a"
9807 #   other = obj.dup
9808 # 
9809 #   a == other      #=> true
9810 #   a.equal? other  #=> false
9811 #   a.equal? a      #=> true
9812 # 
9813 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
9814 # +other+ refer to the same hash key.  This is used by Hash to test members
9815 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
9816 # is synonymous with <code>==</code>.  Subclasses normally continue this
9817 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
9818 # method, but there are exceptions.  <code>Numeric</code> types, for
9819 # example, perform type conversion across <code>==</code>, but not across
9820 # <code>eql?</code>, so:
9821 # 
9822 #    1 == 1.0     #=> true
9823 #    1.eql? 1.0   #=> false
9824 def equal?(other); true || false; end
9825 ##
9826 # Equality --- At the <code>Object</code> level, <code>==</code> returns
9827 # <code>true</code> only if +obj+ and +other+ are the same object.
9828 # Typically, this method is overridden in descendant classes to provide
9829 # class-specific meaning.
9830 # 
9831 # Unlike <code>==</code>, the <code>equal?</code> method should never be
9832 # overridden by subclasses as it is used to determine object identity
9833 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
9834 # same object as <code>b</code>):
9835 # 
9836 #   obj = "a"
9837 #   other = obj.dup
9838 # 
9839 #   a == other      #=> true
9840 #   a.equal? other  #=> false
9841 #   a.equal? a      #=> true
9842 # 
9843 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
9844 # +other+ refer to the same hash key.  This is used by Hash to test members
9845 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
9846 # is synonymous with <code>==</code>.  Subclasses normally continue this
9847 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
9848 # method, but there are exceptions.  <code>Numeric</code> types, for
9849 # example, perform type conversion across <code>==</code>, but not across
9850 # <code>eql?</code>, so:
9851 # 
9852 #    1 == 1.0     #=> true
9853 #    1.eql? 1.0   #=> false
9854 def eql?(other); true || false; end
9855 ##
9856 # Comparison---Returns -1, 0, +1 or nil depending on whether +module+
9857 # includes +other_module+, they are the same, or if +module+ is included by
9858 # +other_module+. This is the basis for the tests in Comparable.
9859 # 
9860 # Returns +nil+ if +module+ has no relationship with +other_module+, if
9861 # +other_module+ is not a module, or if the two values are incomparable.
9862 def <=>; 1 || nil; end
9863 ##
9864 # Returns true if <i>mod</i> is a subclass of <i>other</i>. Returns
9865 # <code>nil</code> if there's no relationship between the two.
9866 # (Think of the relationship in terms of the class definition:
9867 # "class A<B" implies "A<B").
9868 def <; true || false || nil; end
9869 ##
9870 # Returns true if <i>mod</i> is a subclass of <i>other</i> or
9871 # is the same as <i>other</i>. Returns
9872 # <code>nil</code> if there's no relationship between the two.
9873 # (Think of the relationship in terms of the class definition:
9874 # "class A<B" implies "A<B").
9875 def <=; true || false || nil; end
9876 ##
9877 # Returns true if <i>mod</i> is an ancestor of <i>other</i>. Returns
9878 # <code>nil</code> if there's no relationship between the two.
9879 # (Think of the relationship in terms of the class definition:
9880 # "class A<B" implies "B>A").
9881 def >; true || false || nil; end
9882 ##
9883 # Returns true if <i>mod</i> is an ancestor of <i>other</i>, or the
9884 # two modules are the same. Returns
9885 # <code>nil</code> if there's no relationship between the two.
9886 # (Think of the relationship in terms of the class definition:
9887 # "class A<B" implies "B>A").
9888 def >=; true || false || nil; end
9889 ##
9890 # Return a string representing this module or class. For basic
9891 # classes and modules, this is the name. For singletons, we
9892 # show information on the thing we're attached to as well.
9893 def to_s; ''; end
9894 ##
9895 # Returns the list of modules included in <i>mod</i>.
9896 # 
9897 #    module Mixin
9898 #    end
9899 # 
9900 #    module Outer
9901 #      include Mixin
9902 #    end
9903 # 
9904 #    Mixin.included_modules   #=> []
9905 #    Outer.included_modules   #=> [Mixin]
9906 def included_modules; []; end
9907 ##
9908 # Returns <code>true</code> if <i>module</i> is included in
9909 # <i>mod</i> or one of <i>mod</i>'s ancestors.
9910 # 
9911 #    module A
9912 #    end
9913 #    class B
9914 #      include A
9915 #    end
9916 #    class C < B
9917 #    end
9918 #    B.include?(A)   #=> true
9919 #    C.include?(A)   #=> true
9920 #    A.include?(A)   #=> false
9921 def include?(modul); true || false; end
9922 ##
9923 # Returns the name of the module <i>mod</i>.  Returns nil for anonymous modules.
9924 def name; ''; end
9925 ##
9926 # Returns a list of modules included in <i>mod</i> (including
9927 # <i>mod</i> itself).
9928 # 
9929 #    module Mod
9930 #      include Math
9931 #      include Comparable
9932 #    end
9933 # 
9934 #    Mod.ancestors    #=> [Mod, Comparable, Math]
9935 #    Math.ancestors   #=> [Math]
9936 def ancestors; []; end
9937 ##
9938 # Creates instance variables and corresponding methods that return the
9939 # value of each instance variable. Equivalent to calling
9940 # ``<code>attr</code><i>:name</i>'' on each name in turn.
9941 # String arguments are converted to symbols.
9942 def attr_reader(); end
9943 ##
9944 # Creates an accessor method to allow assignment to the attribute
9945 # <i>symbol</i><code>.id2name</code>.
9946 # String arguments are converted to symbols.
9947 def attr_writer(); end
9948 ##
9949 # Defines a named attribute for this module, where the name is
9950 # <i>symbol.</i><code>id2name</code>, creating an instance variable
9951 # (<code>@name</code>) and a corresponding access method to read it.
9952 # Also creates a method called <code>name=</code> to set the attribute.
9953 # String arguments are converted to symbols.
9954 # 
9955 #    module Mod
9956 #      attr_accessor(:one, :two)
9957 #    end
9958 #    Mod.instance_methods.sort   #=> [:one, :one=, :two, :two=]
9959 def attr_accessor(); end
9960 ##
9961 # Creates a new anonymous module. If a block is given, it is passed
9962 # the module object, and the block is evaluated in the context of this
9963 # module using <code>module_eval</code>.
9964 # 
9965 #    fred = Module.new do
9966 #      def meth1
9967 #        "hello"
9968 #      end
9969 #      def meth2
9970 #        "bye"
9971 #      end
9972 #    end
9973 #    a = "my string"
9974 #    a.extend(fred)   #=> "my string"
9975 #    a.meth1          #=> "hello"
9976 #    a.meth2          #=> "bye"
9977 # 
9978 # Assign the module to a constant (name starting uppercase) if you
9979 # want to treat it like a regular module.
9980 def self.new; end
9981 ##
9982 # Returns an array containing the names of the public and protected instance
9983 # methods in the receiver. For a module, these are the public and protected methods;
9984 # for a class, they are the instance (not singleton) methods. With no
9985 # argument, or with an argument that is <code>false</code>, the
9986 # instance methods in <i>mod</i> are returned, otherwise the methods
9987 # in <i>mod</i> and <i>mod</i>'s superclasses are returned.
9988 # 
9989 #    module A
9990 #      def method1()  end
9991 #    end
9992 #    class B
9993 #      def method2()  end
9994 #    end
9995 #    class C < B
9996 #      def method3()  end
9997 #    end
9998 # 
9999 #    A.instance_methods                #=> [:method1]
10000 #    B.instance_methods(false)         #=> [:method2]
10001 #    C.instance_methods(false)         #=> [:method3]
10002 #    C.instance_methods(true).length   #=> 43
10003 def instance_methods(include_super=true); []; end
10004 ##
10005 # Returns a list of the public instance methods defined in <i>mod</i>.
10006 # If the optional parameter is not <code>false</code>, the methods of
10007 # any ancestors are included.
10008 def public_instance_methods(include_super=true); []; end
10009 ##
10010 # Returns a list of the protected instance methods defined in
10011 # <i>mod</i>. If the optional parameter is not <code>false</code>, the
10012 # methods of any ancestors are included.
10013 def protected_instance_methods(include_super=true); []; end
10014 ##
10015 # Returns a list of the private instance methods defined in
10016 # <i>mod</i>. If the optional parameter is not <code>false</code>, the
10017 # methods of any ancestors are included.
10018 # 
10019 #    module Mod
10020 #      def method1()  end
10021 #      private :method1
10022 #      def method2()  end
10023 #    end
10024 #    Mod.instance_methods           #=> [:method2]
10025 #    Mod.private_instance_methods   #=> [:method1]
10026 def private_instance_methods(include_super=true); []; end
10027 ##
10028 # Checks for a constant with the given name in <i>mod</i>
10029 # If +inherit+ is set, the lookup will also search
10030 # the ancestors (and +Object+ if <i>mod</i> is a +Module+.)
10031 # 
10032 # The value of the constant is returned if a definition is found,
10033 # otherwise a +NameError+ is raised.
10034 # 
10035 #    Math.const_get(:PI)   #=> 3.14159265358979
10036 # 
10037 # This method will recursively look up constant names if a namespaced
10038 # class name is provided.  For example:
10039 # 
10040 #    module Foo; class Bar; end end
10041 #    Object.const_get 'Foo::Bar'
10042 # 
10043 # The +inherit+ flag is respected on each lookup.  For example:
10044 # 
10045 #    module Foo
10046 #      class Bar
10047 #        VAL = 10
10048 #      end
10049 # 
10050 #      class Baz < Bar; end
10051 #    end
10052 # 
10053 #    Object.const_get 'Foo::Baz::VAL'         # => 10
10054 #    Object.const_get 'Foo::Baz::VAL', false  # => NameError
10055 def const_get(sym, inherit=true); Object.new; end
10056 ##
10057 # Sets the named constant to the given object, returning that object.
10058 # Creates a new constant if no constant with the given name previously
10059 # existed.
10060 # 
10061 #    Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0)   #=> 3.14285714285714
10062 #    Math::HIGH_SCHOOL_PI - Math::PI              #=> 0.00126448926734968
10063 def const_set(sym, obj); Object.new; end
10064 ##
10065 # Checks for a constant with the given name in <i>mod</i>
10066 # If +inherit+ is set, the lookup will also search
10067 # the ancestors (and +Object+ if <i>mod</i> is a +Module+.)
10068 # 
10069 # Returns whether or not a definition is found:
10070 # 
10071 #    Math.const_defined? "PI"   #=> true
10072 #    IO.const_defined? :SYNC   #=> true
10073 #    IO.const_defined? :SYNC, false   #=> false
10074 def const_defined?(sym, inherit=true); true || false; end
10075 ##
10076 # Removes the definition of the given constant, returning that
10077 # constant's previous value.  If that constant referred to
10078 # a module, this will not change that module's name and can lead
10079 # to confusion.
10080 def remove_const(sym); Object.new; end
10081 ##
10082 # Invoked when a reference is made to an undefined constant in
10083 # <i>mod</i>. It is passed a symbol for the undefined constant, and
10084 # returns a value to be used for that constant. The
10085 # following code is an example of the same:
10086 # 
10087 #   def Foo.const_missing(name)
10088 #     name # return the constant name as Symbol
10089 #   end
10090 # 
10091 #   Foo::UNDEFINED_CONST    #=> :UNDEFINED_CONST: symbol returned
10092 # 
10093 # In the next example when a reference is made to an undefined constant,
10094 # it attempts to load a file whose name is the lowercase version of the
10095 # constant (thus class <code>Fred</code> is assumed to be in file
10096 # <code>fred.rb</code>).  If found, it returns the loaded class. It
10097 # therefore implements an autoload feature similar to Kernel#autoload and
10098 # Module#autoload.
10099 # 
10100 #   def Object.const_missing(name)
10101 #     @looked_for ||= {}
10102 #     str_name = name.to_s
10103 #     raise "Class not found: #{name}" if @looked_for[str_name]
10104 #     @looked_for[str_name] = 1
10105 #     file = str_name.downcase
10106 #     require file
10107 #     klass = const_get(name)
10108 #     return klass if klass
10109 #     raise "Class not found: #{name}"
10110 #   end
10111 def const_missing(sym); Object.new; end
10112 ##
10113 # Returns an array of the names of class variables in <i>mod</i>.
10114 # This includes the names of class variables in any included
10115 # modules, unless the <i>inherit</i> parameter is set to
10116 # <code>false</code>.
10117 # 
10118 #    class One
10119 #      @@var1 = 1
10120 #    end
10121 #    class Two < One
10122 #      @@var2 = 2
10123 #    end
10124 #    One.class_variables   #=> [:@@var1]
10125 #    Two.class_variables   #=> [:@@var2, :@@var1]
10126 def class_variables(inherit=true); []; end
10127 ##
10128 # Removes the definition of the <i>sym</i>, returning that
10129 # constant's value.
10130 # 
10131 #    class Dummy
10132 #      @@var = 99
10133 #      puts @@var
10134 #      remove_class_variable(:@@var)
10135 #      p(defined? @@var)
10136 #    end
10137 # 
10138 # <em>produces:</em>
10139 # 
10140 #    99
10141 #    nil
10142 def remove_class_variable(sym); Object.new; end
10143 ##
10144 # Returns the value of the given class variable (or throws a
10145 # <code>NameError</code> exception). The <code>@@</code> part of the
10146 # variable name should be included for regular class variables
10147 # String arguments are converted to symbols.
10148 # 
10149 #    class Fred
10150 #      @@foo = 99
10151 #    end
10152 #    Fred.class_variable_get(:@@foo)     #=> 99
10153 def class_variable_get(symbol); Object.new; end
10154 ##
10155 # Sets the class variable names by <i>symbol</i> to
10156 # <i>object</i>.
10157 # If the class variable name is passed as a string, that string
10158 # is converted to a symbol.
10159 # 
10160 #    class Fred
10161 #      @@foo = 99
10162 #      def foo
10163 #        @@foo
10164 #      end
10165 #    end
10166 #    Fred.class_variable_set(:@@foo, 101)     #=> 101
10167 #    Fred.new.foo                             #=> 101
10168 def class_variable_set(symbol, obj); Object.new; end
10169 ##
10170 # Returns <code>true</code> if the given class variable is defined
10171 # in <i>obj</i>.
10172 # String arguments are converted to symbols.
10173 # 
10174 #    class Fred
10175 #      @@foo = 99
10176 #    end
10177 #    Fred.class_variable_defined?(:@@foo)    #=> true
10178 #    Fred.class_variable_defined?(:@@bar)    #=> false
10179 def class_variable_defined?(symbol); true || false; end
10180 ##
10181 # Makes a list of existing constants public.
10182 def public_constant(); Module.new; end
10183 ##
10184 # Makes a list of existing constants private.
10185 def private_constant(); Module.new; end
10186 end
10187 
10188 ##
10189 # A rational number can be represented as a paired integer number;
10190 # a/b (b>0).  Where a is numerator and b is denominator.  Integer a
10191 # equals rational a/1 mathematically.
10192 # 
10193 # In ruby, you can create rational object with Rational, to_r or
10194 # rationalize method.  The return values will be irreducible.
10195 # 
10196 #    Rational(1)      #=> (1/1)
10197 #    Rational(2, 3)   #=> (2/3)
10198 #    Rational(4, -6)  #=> (-2/3)
10199 #    3.to_r           #=> (3/1)
10200 # 
10201 # You can also create rational object from floating-point numbers or
10202 # strings.
10203 # 
10204 #    Rational(0.3)    #=> (5404319552844595/18014398509481984)
10205 #    Rational('0.3')  #=> (3/10)
10206 #    Rational('2/3')  #=> (2/3)
10207 # 
10208 #    0.3.to_r         #=> (5404319552844595/18014398509481984)
10209 #    '0.3'.to_r       #=> (3/10)
10210 #    '2/3'.to_r       #=> (2/3)
10211 #    0.3.rationalize  #=> (3/10)
10212 # 
10213 # A rational object is an exact number, which helps you to write
10214 # program without any rounding errors.
10215 # 
10216 #    10.times.inject(0){|t,| t + 0.1}              #=> 0.9999999999999999
10217 #    10.times.inject(0){|t,| t + Rational('0.1')}  #=> (1/1)
10218 # 
10219 # However, when an expression has inexact factor (numerical value or
10220 # operation), will produce an inexact result.
10221 # 
10222 #    Rational(10) / 3   #=> (10/3)
10223 #    Rational(10) / 3.0 #=> 3.3333333333333335
10224 # 
10225 #    Rational(-8) ** Rational(1, 3)
10226 #                       #=> (1.0000000000000002+1.7320508075688772i)
10227 class Rational < Numeric
10228 class Compatible < Object
10229 end
10230 
10231 ##
10232 # Returns the numerator.
10233 # 
10234 #    Rational(7).numerator        #=> 7
10235 #    Rational(7, 1).numerator     #=> 7
10236 #    Rational(9, -4).numerator    #=> -9
10237 #    Rational(-2, -10).numerator  #=> 1
10238 def numerator; 0; end
10239 ##
10240 # Returns the denominator (always positive).
10241 # 
10242 #    Rational(7).denominator             #=> 1
10243 #    Rational(7, 1).denominator          #=> 1
10244 #    Rational(9, -4).denominator         #=> 4
10245 #    Rational(-2, -10).denominator       #=> 5
10246 #    rat.numerator.gcd(rat.denominator)  #=> 1
10247 def denominator; 0; end
10248 ##
10249 # Performs addition.
10250 # 
10251 #    Rational(2, 3)  + Rational(2, 3)   #=> (4/3)
10252 #    Rational(900)   + Rational(1)      #=> (900/1)
10253 #    Rational(-2, 9) + Rational(-9, 2)  #=> (-85/18)
10254 #    Rational(9, 8)  + 4                #=> (41/8)
10255 #    Rational(20, 9) + 9.8              #=> 12.022222222222222
10256 def +; 0; end
10257 ##
10258 # Performs subtraction.
10259 # 
10260 #    Rational(2, 3)  - Rational(2, 3)   #=> (0/1)
10261 #    Rational(900)   - Rational(1)      #=> (899/1)
10262 #    Rational(-2, 9) - Rational(-9, 2)  #=> (77/18)
10263 #    Rational(9, 8)  - 4                #=> (23/8)
10264 #    Rational(20, 9) - 9.8              #=> -7.577777777777778
10265 def -; 0; end
10266 ##
10267 # Performs multiplication.
10268 # 
10269 #    Rational(2, 3)  * Rational(2, 3)   #=> (4/9)
10270 #    Rational(900)   * Rational(1)      #=> (900/1)
10271 #    Rational(-2, 9) * Rational(-9, 2)  #=> (1/1)
10272 #    Rational(9, 8)  * 4                #=> (9/2)
10273 #    Rational(20, 9) * 9.8              #=> 21.77777777777778
10274 def *; 0; end
10275 ##
10276 # Performs division.
10277 # 
10278 #    Rational(2, 3)  / Rational(2, 3)   #=> (1/1)
10279 #    Rational(900)   / Rational(1)      #=> (900/1)
10280 #    Rational(-2, 9) / Rational(-9, 2)  #=> (4/81)
10281 #    Rational(9, 8)  / 4                #=> (9/32)
10282 #    Rational(20, 9) / 9.8              #=> 0.22675736961451246
10283 def /; 0; end
10284 ##
10285 # Performs division.
10286 # 
10287 #    Rational(2, 3)  / Rational(2, 3)   #=> (1/1)
10288 #    Rational(900)   / Rational(1)      #=> (900/1)
10289 #    Rational(-2, 9) / Rational(-9, 2)  #=> (4/81)
10290 #    Rational(9, 8)  / 4                #=> (9/32)
10291 #    Rational(20, 9) / 9.8              #=> 0.22675736961451246
10292 def quo(numeric); 0; end
10293 ##
10294 # Performs division and returns the value as a float.
10295 # 
10296 #    Rational(2, 3).fdiv(1)       #=> 0.6666666666666666
10297 #    Rational(2, 3).fdiv(0.5)     #=> 1.3333333333333333
10298 #    Rational(2).fdiv(3)          #=> 0.6666666666666666
10299 def fdiv(numeric); 0.0; end
10300 ##
10301 # Performs exponentiation.
10302 # 
10303 #    Rational(2)    ** Rational(3)    #=> (8/1)
10304 #    Rational(10)   ** -2             #=> (1/100)
10305 #    Rational(10)   ** -2.0           #=> 0.01
10306 #    Rational(-4)   ** Rational(1,2)  #=> (1.2246063538223773e-16+2.0i)
10307 #    Rational(1, 2) ** 0              #=> (1/1)
10308 #    Rational(1, 2) ** 0.0            #=> 1.0
10309 def **; 0; end
10310 ##
10311 # Performs comparison and returns -1, 0, or +1.
10312 # 
10313 # +nil+ is returned if the two values are incomparable.
10314 # 
10315 #    Rational(2, 3)  <=> Rational(2, 3)  #=> 0
10316 #    Rational(5)     <=> 5               #=> 0
10317 #    Rational(2,3)   <=> Rational(1,3)   #=> 1
10318 #    Rational(1,3)   <=> 1               #=> -1
10319 #    Rational(1,3)   <=> 0.3             #=> 1
10320 def <=>; 1 || nil; end
10321 ##
10322 # Returns true if rat equals object numerically.
10323 # 
10324 #    Rational(2, 3)  == Rational(2, 3)   #=> true
10325 #    Rational(5)     == 5                #=> true
10326 #    Rational(0)     == 0.0              #=> true
10327 #    Rational('1/3') == 0.33             #=> false
10328 #    Rational('1/2') == '1/2'            #=> false
10329 def ==; true || false; end
10330 ##
10331 # Returns the truncated value (toward negative infinity).
10332 # 
10333 #    Rational(3).floor      #=> 3
10334 #    Rational(2, 3).floor   #=> 0
10335 #    Rational(-3, 2).floor  #=> -1
10336 # 
10337 #           decimal      -  1  2  3 . 4  5  6
10338 #                          ^  ^  ^  ^   ^  ^
10339 #          precision      -3 -2 -1  0  +1 +2
10340 # 
10341 #    '%f' % Rational('-123.456').floor(+1)  #=> "-123.500000"
10342 #    '%f' % Rational('-123.456').floor(-1)  #=> "-130.000000"
10343 def floor; Rational.new; end
10344 ##
10345 # Returns the truncated value (toward positive infinity).
10346 # 
10347 #    Rational(3).ceil      #=> 3
10348 #    Rational(2, 3).ceil   #=> 1
10349 #    Rational(-3, 2).ceil  #=> -1
10350 # 
10351 #           decimal      -  1  2  3 . 4  5  6
10352 #                          ^  ^  ^  ^   ^  ^
10353 #          precision      -3 -2 -1  0  +1 +2
10354 # 
10355 #    '%f' % Rational('-123.456').ceil(+1)  #=> "-123.400000"
10356 #    '%f' % Rational('-123.456').ceil(-1)  #=> "-120.000000"
10357 def ceil; Rational.new; end
10358 ##
10359 # Returns the truncated value (toward zero).
10360 # 
10361 #    Rational(3).truncate      #=> 3
10362 #    Rational(2, 3).truncate   #=> 0
10363 #    Rational(-3, 2).truncate  #=> -1
10364 # 
10365 #           decimal      -  1  2  3 . 4  5  6
10366 #                          ^  ^  ^  ^   ^  ^
10367 #          precision      -3 -2 -1  0  +1 +2
10368 # 
10369 #    '%f' % Rational('-123.456').truncate(+1)  #=>  "-123.400000"
10370 #    '%f' % Rational('-123.456').truncate(-1)  #=>  "-120.000000"
10371 def truncate; Rational.new; end
10372 ##
10373 # Returns the truncated value (toward the nearest integer;
10374 # 0.5 => 1; -0.5 => -1).
10375 # 
10376 #    Rational(3).round      #=> 3
10377 #    Rational(2, 3).round   #=> 1
10378 #    Rational(-3, 2).round  #=> -2
10379 # 
10380 #           decimal      -  1  2  3 . 4  5  6
10381 #                          ^  ^  ^  ^   ^  ^
10382 #          precision      -3 -2 -1  0  +1 +2
10383 # 
10384 #    '%f' % Rational('-123.456').round(+1)  #=> "-123.500000"
10385 #    '%f' % Rational('-123.456').round(-1)  #=> "-120.000000"
10386 def round; Rational.new; end
10387 ##
10388 # Returns the truncated value as an integer.
10389 # 
10390 # Equivalent to
10391 #    rat.truncate.
10392 # 
10393 #    Rational(2, 3).to_i   #=> 0
10394 #    Rational(3).to_i      #=> 3
10395 #    Rational(300.6).to_i  #=> 300
10396 #    Rational(98,71).to_i  #=> 1
10397 #    Rational(-30,2).to_i  #=> -15
10398 def to_i; 0; end
10399 ##
10400 # Return the value as a float.
10401 # 
10402 #    Rational(2).to_f      #=> 2.0
10403 #    Rational(9, 4).to_f   #=> 2.25
10404 #    Rational(-3, 4).to_f  #=> -0.75
10405 #    Rational(20, 3).to_f  #=> 6.666666666666667
10406 def to_f; 0.0; end
10407 ##
10408 # Returns self.
10409 # 
10410 #    Rational(2).to_r      #=> (2/1)
10411 #    Rational(-8, 6).to_r  #=> (-4/3)
10412 def to_r; self; end
10413 ##
10414 # Returns a simpler approximation of the value if the optional
10415 # argument eps is given (rat-|eps| <= result <= rat+|eps|), self
10416 # otherwise.
10417 # 
10418 #    r = Rational(5033165, 16777216)
10419 #    r.rationalize                    #=> (5033165/16777216)
10420 #    r.rationalize(Rational('0.01'))  #=> (3/10)
10421 #    r.rationalize(Rational('0.1'))   #=> (1/3)
10422 def rationalize; Rational.new; end
10423 ##
10424 # Returns the value as a string.
10425 # 
10426 #    Rational(2).to_s      #=> "2/1"
10427 #    Rational(-8, 6).to_s  #=> "-4/3"
10428 #    Rational('1/2').to_s  #=> "1/2"
10429 def to_s; ''; end
10430 ##
10431 # Returns the value as a string for inspection.
10432 # 
10433 #    Rational(2).inspect      #=> "(2/1)"
10434 #    Rational(-8, 6).inspect  #=> "(-4/3)"
10435 #    Rational('1/2').inspect  #=> "(1/2)"
10436 def inspect; ''; end
10437 end
10438 
10439 class Integer < Object
10440 ##
10441 # Returns the greatest common divisor (always positive).  0.gcd(x)
10442 # and x.gcd(0) return abs(x).
10443 # 
10444 #    2.gcd(2)                    #=> 2
10445 #    3.gcd(-7)                   #=> 1
10446 #    ((1<<31)-1).gcd((1<<61)-1)  #=> 1
10447 def gcd(int2); 0; end
10448 ##
10449 # Returns the least common multiple (always positive).  0.lcm(x) and
10450 # x.lcm(0) return zero.
10451 # 
10452 #    2.lcm(2)                    #=> 2
10453 #    3.lcm(-7)                   #=> 21
10454 #    ((1<<31)-1).lcm((1<<61)-1)  #=> 4951760154835678088235319297
10455 def lcm(int2); 0; end
10456 ##
10457 # Returns an array; [int.gcd(int2), int.lcm(int2)].
10458 # 
10459 #    2.gcdlcm(2)                    #=> [2, 2]
10460 #    3.gcdlcm(-7)                   #=> [1, 21]
10461 #    ((1<<31)-1).gcdlcm((1<<61)-1)  #=> [1, 4951760154835678088235319297]
10462 def gcdlcm(int2); []; end
10463 ##
10464 # Returns self.
10465 def numerator; self; end
10466 ##
10467 # Returns 1.
10468 def denominator; 1; end
10469 ##
10470 # Returns the value as a rational.
10471 # 
10472 #    1.to_r        #=> (1/1)
10473 #    (1<<64).to_r  #=> (18446744073709551616/1)
10474 def to_r; Rational.new; end
10475 ##
10476 # Returns the value as a rational.  The optional argument eps is
10477 # always ignored.
10478 def rationalize(eps=0); Rational.new; end
10479 ##
10480 # Always returns <code>true</code>.
10481 def integer?; true; end
10482 ##
10483 # Returns <code>true</code> if <i>int</i> is an odd number.
10484 def odd?; true || false; end
10485 ##
10486 # Returns <code>true</code> if <i>int</i> is an even number.
10487 def even?; true || false; end
10488 ##
10489 # Iterates <em>block</em>, passing in integer values from <i>int</i>
10490 # up to and including <i>limit</i>.
10491 # 
10492 # If no block is given, an enumerator is returned instead.
10493 # 
10494 #    5.upto(10) { |i| print i, " " }
10495 # 
10496 # <em>produces:</em>
10497 # 
10498 #    5 6 7 8 9 10
10499 def upto(limit, &block); Enumerator.new; end
10500 ##
10501 # Iterates <em>block</em>, passing decreasing values from <i>int</i>
10502 # down to and including <i>limit</i>.
10503 # 
10504 # If no block is given, an enumerator is returned instead.
10505 # 
10506 #    5.downto(1) { |n| print n, ".. " }
10507 #    print "  Liftoff!\n"
10508 # 
10509 # <em>produces:</em>
10510 # 
10511 #    5.. 4.. 3.. 2.. 1..   Liftoff!
10512 def downto(limit, &block); Enumerator.new; end
10513 ##
10514 # Iterates block <i>int</i> times, passing in values from zero to
10515 # <i>int</i> - 1.
10516 # 
10517 # If no block is given, an enumerator is returned instead.
10518 # 
10519 #    5.times do |i|
10520 #      print i, " "
10521 #    end
10522 # 
10523 # <em>produces:</em>
10524 # 
10525 #    0 1 2 3 4
10526 def times(&block); Enumerator.new; end
10527 ##
10528 # Returns the <code>Integer</code> equal to <i>int</i> + 1.
10529 # 
10530 #    1.next      #=> 2
10531 #    (-1).next   #=> 0
10532 def next; 0; end
10533 ##
10534 # Returns the <code>Integer</code> equal to <i>int</i> + 1.
10535 # 
10536 #    1.next      #=> 2
10537 #    (-1).next   #=> 0
10538 def succ; 0; end
10539 ##
10540 # Returns the <code>Integer</code> equal to <i>int</i> - 1.
10541 # 
10542 #    1.pred      #=> 0
10543 #    (-1).pred   #=> -2
10544 def pred; 0; end
10545 ##
10546 # Returns a string containing the character represented by the
10547 # receiver's value according to +encoding+.
10548 # 
10549 #    65.chr    #=> "A"
10550 #    230.chr   #=> "\346"
10551 #    255.chr(Encoding::UTF_8)   #=> "\303\277"
10552 def chr(encoding=0); ''; end
10553 ##
10554 # Returns the int itself.
10555 # 
10556 #    ?a.ord    #=> 97
10557 # 
10558 # This method is intended for compatibility to
10559 # character constant in Ruby 1.9.
10560 # For example, ?a.ord returns 97 both in 1.8 and 1.9.
10561 def ord; self; end
10562 ##
10563 # As <i>int</i> is already an <code>Integer</code>, all these
10564 # methods simply return the receiver.
10565 def to_i; 0; end
10566 ##
10567 # As <i>int</i> is already an <code>Integer</code>, all these
10568 # methods simply return the receiver.
10569 def to_int; 0; end
10570 ##
10571 # As <i>int</i> is already an <code>Integer</code>, all these
10572 # methods simply return the receiver.
10573 def floor; 0; end
10574 ##
10575 # As <i>int</i> is already an <code>Integer</code>, all these
10576 # methods simply return the receiver.
10577 def ceil; 0; end
10578 ##
10579 # As <i>int</i> is already an <code>Integer</code>, all these
10580 # methods simply return the receiver.
10581 def truncate; 0; end
10582 ##
10583 # Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits).
10584 # Precision may be negative.  Returns a floating point number when +ndigits+
10585 # is positive, +self+ for zero, and round down for negative.
10586 # 
10587 #    1.round        #=> 1
10588 #    1.round(2)     #=> 1.0
10589 #    15.round(-1)   #=> 20
10590 def round(ndigits=0); 0 || 0.0; end
10591 end
10592 
10593 class Numeric < Object
10594 include Comparable
10595 ##
10596 # Returns the numerator.
10597 def numerator; 0; end
10598 ##
10599 # Returns the denominator (always positive).
10600 def denominator; 0; end
10601 ##
10602 # If <i>aNumeric</i> is the same type as <i>num</i>, returns an array
10603 # containing <i>aNumeric</i> and <i>num</i>. Otherwise, returns an
10604 # array with both <i>aNumeric</i> and <i>num</i> represented as
10605 # <code>Float</code> objects. This coercion mechanism is used by
10606 # Ruby to handle mixed-type numeric operations: it is intended to
10607 # find a compatible common type between the two operands of the operator.
10608 # 
10609 #    1.coerce(2.5)   #=> [2.5, 1.0]
10610 #    1.2.coerce(3)   #=> [3.0, 1.2]
10611 #    1.coerce(2)     #=> [2, 1]
10612 def coerce(numeric); []; end
10613 ##
10614 # Returns the corresponding imaginary number.
10615 # Not available for complex numbers.
10616 def i; Complex.new; end
10617 ##
10618 # Unary Plus---Returns the receiver's value.
10619 def +@; 0; end
10620 ##
10621 # Unary Minus---Returns the receiver's value, negated.
10622 def -@; 0; end
10623 ##
10624 # Returns zero if +number+ equals +other+, otherwise +nil+ is returned if the
10625 # two values are incomparable.
10626 def <=>; 0 || nil; end
10627 ##
10628 # Returns <code>true</code> if <i>num</i> and <i>numeric</i> are the
10629 # same type and have equal values.
10630 # 
10631 #    1 == 1.0          #=> true
10632 #    1.eql?(1.0)       #=> false
10633 #    (1.0).eql?(1.0)   #=> true
10634 def eql?(numeric); true || false; end
10635 ##
10636 # Returns most exact division (rational for integers, float for floats).
10637 def quo(numeric); 0; end
10638 ##
10639 # Returns float division.
10640 def fdiv(numeric); 0.0; end
10641 ##
10642 # Uses <code>/</code> to perform division, then converts the result to
10643 # an integer. <code>numeric</code> does not define the <code>/</code>
10644 # operator; this is left to subclasses.
10645 # 
10646 # Equivalent to
10647 # <i>num</i>.<code>divmod(</code><i>aNumeric</i><code>)[0]</code>.
10648 # 
10649 # See <code>Numeric#divmod</code>.
10650 def div(numeric); 0; end
10651 ##
10652 # Returns an array containing the quotient and modulus obtained by
10653 # dividing <i>num</i> by <i>numeric</i>. If <code>q, r =
10654 # x.divmod(y)</code>, then
10655 # 
10656 #     q = floor(x/y)
10657 #     x = q*y+r
10658 # 
10659 # The quotient is rounded toward -infinity, as shown in the following table:
10660 # 
10661 #    a    |  b  |  a.divmod(b)  |   a/b   | a.modulo(b) | a.remainder(b)
10662 #   ------+-----+---------------+---------+-------------+---------------
10663 #    13   |  4  |   3,    1     |   3     |    1        |     1
10664 #   ------+-----+---------------+---------+-------------+---------------
10665 #    13   | -4  |  -4,   -3     |  -4     |   -3        |     1
10666 #   ------+-----+---------------+---------+-------------+---------------
10667 #   -13   |  4  |  -4,    3     |  -4     |    3        |    -1
10668 #   ------+-----+---------------+---------+-------------+---------------
10669 #   -13   | -4  |   3,   -1     |   3     |   -1        |    -1
10670 #   ------+-----+---------------+---------+-------------+---------------
10671 #    11.5 |  4  |   2,    3.5   |   2.875 |    3.5      |     3.5
10672 #   ------+-----+---------------+---------+-------------+---------------
10673 #    11.5 | -4  |  -3,   -0.5   |  -2.875 |   -0.5      |     3.5
10674 #   ------+-----+---------------+---------+-------------+---------------
10675 #   -11.5 |  4  |  -3,    0.5   |  -2.875 |    0.5      |    -3.5
10676 #   ------+-----+---------------+---------+-------------+---------------
10677 #   -11.5 | -4  |   2,   -3.5   |   2.875 |   -3.5      |    -3.5
10678 # 
10679 # Examples
10680 # 
10681 #    11.divmod(3)         #=> [3, 2]
10682 #    11.divmod(-3)        #=> [-4, -1]
10683 #    11.divmod(3.5)       #=> [3, 0.5]
10684 #    (-11).divmod(3.5)    #=> [-4, 3.0]
10685 #    (11.5).divmod(3.5)   #=> [3, 1.0]
10686 def divmod(numeric); []; end
10687 ##
10688 #    x.modulo(y) means x-y*(x/y).floor
10689 # 
10690 # Equivalent to
10691 # <i>num</i>.<code>divmod(</code><i>aNumeric</i><code>)[1]</code>.
10692 # 
10693 # See <code>Numeric#divmod</code>.
10694 def modulo(numeric); 0; end
10695 ##
10696 #    x.remainder(y) means x-y*(x/y).truncate
10697 # 
10698 # See <code>Numeric#divmod</code>.
10699 def remainder(numeric); 0; end
10700 ##
10701 # Returns the absolute value of <i>num</i>.
10702 # 
10703 #    12.abs         #=> 12
10704 #    (-34.56).abs   #=> 34.56
10705 #    -34.56.abs     #=> 34.56
10706 def abs; 0; end
10707 ##
10708 # Returns the absolute value of <i>num</i>.
10709 # 
10710 #    12.abs         #=> 12
10711 #    (-34.56).abs   #=> 34.56
10712 #    -34.56.abs     #=> 34.56
10713 def magnitude; 0; end
10714 ##
10715 # Invokes the child class's +to_i+ method to convert +num+ to an integer.
10716 # 
10717 #     1.0.class => Float
10718 #     1.0.to_int.class => Fixnum
10719 #     1.0.to_i.class => Fixnum
10720 def to_int; 0; end
10721 ##
10722 # Returns <code>true</code> if <i>num</i> is a <code>Real</code>
10723 # (i.e. non <code>Complex</code>).
10724 def real?; true || false; end
10725 ##
10726 # Returns +true+ if +num+ is an Integer (including Fixnum and Bignum).
10727 # 
10728 #     (1.0).integer? #=> false
10729 #     (1).integer?   #=> true
10730 def integer?; true || false; end
10731 ##
10732 # Returns <code>true</code> if <i>num</i> has a zero value.
10733 def zero?; true || false; end
10734 ##
10735 # Returns +self+ if <i>num</i> is not zero, <code>nil</code>
10736 # otherwise. This behavior is useful when chaining comparisons:
10737 # 
10738 #    a = %w( z Bb bB bb BB a aA Aa AA A )
10739 #    b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
10740 #    b   #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
10741 def nonzero?; self || nil; end
10742 ##
10743 # Returns the largest integer less than or equal to <i>num</i>.
10744 # <code>Numeric</code> implements this by converting <i>anInteger</i>
10745 # to a <code>Float</code> and invoking <code>Float#floor</code>.
10746 # 
10747 #    1.floor      #=> 1
10748 #    (-1).floor   #=> -1
10749 def floor; 0; end
10750 ##
10751 # Returns the smallest <code>Integer</code> greater than or equal to
10752 # <i>num</i>. Class <code>Numeric</code> achieves this by converting
10753 # itself to a <code>Float</code> then invoking
10754 # <code>Float#ceil</code>.
10755 # 
10756 #    1.ceil        #=> 1
10757 #    1.2.ceil      #=> 2
10758 #    (-1.2).ceil   #=> -1
10759 #    (-1.0).ceil   #=> -1
10760 def ceil; 0; end
10761 ##
10762 # Rounds <i>num</i> to a given precision in decimal digits (default 0 digits).
10763 # Precision may be negative.  Returns a floating point number when <i>ndigits</i>
10764 # is more than zero.  <code>Numeric</code> implements this by converting itself
10765 # to a <code>Float</code> and invoking <code>Float#round</code>.
10766 def round(ndigits=0); 0 || 0.0; end
10767 ##
10768 # Returns <i>num</i> truncated to an integer. <code>Numeric</code>
10769 # implements this by converting its value to a float and invoking
10770 # <code>Float#truncate</code>.
10771 def truncate; 0; end
10772 ##
10773 # Invokes <em>block</em> with the sequence of numbers starting at
10774 # <i>num</i>, incremented by <i>step</i> (default 1) on each
10775 # call. The loop finishes when the value to be passed to the block
10776 # is greater than <i>limit</i> (if <i>step</i> is positive) or less
10777 # than <i>limit</i> (if <i>step</i> is negative). If all the
10778 # arguments are integers, the loop operates using an integer
10779 # counter. If any of the arguments are floating point numbers, all
10780 # are converted to floats, and the loop is executed <i>floor(n +
10781 # n*epsilon)+ 1</i> times, where <i>n = (limit -
10782 # num)/step</i>. Otherwise, the loop starts at <i>num</i>, uses
10783 # either the <code><</code> or <code>></code> operator to compare
10784 # the counter against <i>limit</i>, and increments itself using the
10785 # <code>+</code> operator.
10786 # 
10787 # If no block is given, an enumerator is returned instead.
10788 # 
10789 #    1.step(10, 2) { |i| print i, " " }
10790 #    Math::E.step(Math::PI, 0.2) { |f| print f, " " }
10791 # 
10792 # <em>produces:</em>
10793 # 
10794 #    1 3 5 7 9
10795 #    2.71828182845905 2.91828182845905 3.11828182845905
10796 def step(limit, step=0, &block); Enumerator.new; end
10797 ##
10798 # Returns the value as a complex.
10799 def to_c; Complex.new; end
10800 ##
10801 # Returns self.
10802 def real; self; end
10803 ##
10804 # Returns zero.
10805 def imag; 0; end
10806 ##
10807 # Returns zero.
10808 def imaginary; 0; end
10809 ##
10810 # Returns square of self.
10811 def abs2; 0; end
10812 ##
10813 # Returns 0 if the value is positive, pi otherwise.
10814 def arg; 0 || 0.0; end
10815 ##
10816 # Returns 0 if the value is positive, pi otherwise.
10817 def angle; 0 || 0.0; end
10818 ##
10819 # Returns 0 if the value is positive, pi otherwise.
10820 def phase; 0 || 0.0; end
10821 ##
10822 # Returns an array; [num, 0].
10823 def rect; []; end
10824 ##
10825 # Returns an array; [num.abs, num.arg].
10826 def polar; []; end
10827 ##
10828 # Returns self.
10829 def conj; self; end
10830 ##
10831 # Returns self.
10832 def conjugate; self; end
10833 end
10834 
10835 class Float < Object
10836 ##
10837 # Returns the numerator.  The result is machine dependent.
10838 # 
10839 #    n = 0.3.numerator    #=> 5404319552844595
10840 #    d = 0.3.denominator  #=> 18014398509481984
10841 #    n.fdiv(d)            #=> 0.3
10842 def numerator; 0; end
10843 ##
10844 # Returns the denominator (always positive).  The result is machine
10845 # dependent.
10846 # 
10847 # See numerator.
10848 def denominator; 0; end
10849 ##
10850 # Returns the value as a rational.
10851 # 
10852 # NOTE: 0.3.to_r isn't the same as '0.3'.to_r.  The latter is
10853 # equivalent to '3/10'.to_r, but the former isn't so.
10854 # 
10855 #    2.0.to_r    #=> (2/1)
10856 #    2.5.to_r    #=> (5/2)
10857 #    -0.75.to_r  #=> (-3/4)
10858 #    0.0.to_r    #=> (0/1)
10859 # 
10860 # See rationalize.
10861 def to_r; Rational.new; end
10862 ##
10863 # Returns a simpler approximation of the value (flt-|eps| <= result
10864 # <= flt+|eps|).  if the optional eps is not given, it will be chosen
10865 # automatically.
10866 # 
10867 #    0.3.rationalize          #=> (3/10)
10868 #    1.333.rationalize        #=> (1333/1000)
10869 #    1.333.rationalize(0.01)  #=> (4/3)
10870 # 
10871 # See to_r.
10872 def rationalize(eps=0); Rational.new; end
10873 ##
10874 # Returns a string containing a representation of self. As well as a
10875 # fixed or exponential form of the number, the call may return
10876 # ``<code>NaN</code>'', ``<code>Infinity</code>'', and
10877 # ``<code>-Infinity</code>''.
10878 def to_s; ''; end
10879 ##
10880 # Returns an array with both <i>aNumeric</i> and <i>flt</i> represented
10881 # as <code>Float</code> objects.
10882 # This is achieved by converting <i>aNumeric</i> to a <code>Float</code>.
10883 # 
10884 #    1.2.coerce(3)       #=> [3.0, 1.2]
10885 #    2.5.coerce(1.1)     #=> [1.1, 2.5]
10886 def coerce(numeric); []; end
10887 ##
10888 # Returns float, negated.
10889 def -@; 0.0; end
10890 ##
10891 # Returns a new float which is the sum of <code>float</code>
10892 # and <code>other</code>.
10893 def +; 0.0; end
10894 ##
10895 # Returns a new float which is the difference of <code>float</code>
10896 # and <code>other</code>.
10897 def -; 0.0; end
10898 ##
10899 # Returns a new float which is the product of <code>float</code>
10900 # and <code>other</code>.
10901 def *; 0.0; end
10902 ##
10903 # Returns a new float which is the result of dividing
10904 # <code>float</code> by <code>other</code>.
10905 def /; 0.0; end
10906 ##
10907 # Returns float / numeric.
10908 def quo(numeric); 0.0; end
10909 ##
10910 # Return the modulo after division of +float+ by +other+.
10911 # 
10912 #    6543.21.modulo(137)      #=> 104.21
10913 #    6543.21.modulo(137.24)   #=> 92.9299999999996
10914 def %; 0.0; end
10915 ##
10916 # Return the modulo after division of +float+ by +other+.
10917 # 
10918 #    6543.21.modulo(137)      #=> 104.21
10919 #    6543.21.modulo(137.24)   #=> 92.9299999999996
10920 def modulo(other); 0.0; end
10921 ##
10922 # See Numeric#divmod.
10923 # 
10924 #     42.0.divmod 6 #=> [7, 0.0]
10925 #     42.0.divmod 5 #=> [8, 2.0]
10926 def divmod(numeric); []; end
10927 ##
10928 # Raises <code>float</code> the <code>other</code> power.
10929 # 
10930 #    2.0**3      #=> 8.0
10931 def **; 0.0; end
10932 ##
10933 # Returns <code>true</code> only if <i>obj</i> has the same value
10934 # as <i>flt</i>. Contrast this with <code>Float#eql?</code>, which
10935 # requires <i>obj</i> to be a <code>Float</code>.
10936 # The result of <code>NaN == NaN</code> is undefined, so the
10937 # implementation-dependent value is returned.
10938 # 
10939 #    1.0 == 1   #=> true
10940 def ==; true || false; end
10941 ##
10942 # Returns <code>true</code> only if <i>obj</i> has the same value
10943 # as <i>flt</i>. Contrast this with <code>Float#eql?</code>, which
10944 # requires <i>obj</i> to be a <code>Float</code>.
10945 # The result of <code>NaN == NaN</code> is undefined, so the
10946 # implementation-dependent value is returned.
10947 # 
10948 #    1.0 == 1   #=> true
10949 def ===; true || false; end
10950 ##
10951 # Returns -1, 0, +1 or nil depending on whether +float+ is less than, equal
10952 # to, or greater than +real+. This is the basis for the tests in Comparable.
10953 # 
10954 # The result of <code>NaN <=> NaN</code> is undefined, so the
10955 # implementation-dependent value is returned.
10956 # 
10957 # +nil+ is returned if the two values are incomparable.
10958 def <=>; 1 || nil; end
10959 ##
10960 # <code>true</code> if <code>flt</code> is greater than <code>real</code>.
10961 # The result of <code>NaN > NaN</code> is undefined, so the
10962 # implementation-dependent value is returned.
10963 def >; true || false; end
10964 ##
10965 # <code>true</code> if <code>flt</code> is greater than
10966 # or equal to <code>real</code>.
10967 # The result of <code>NaN >= NaN</code> is undefined, so the
10968 # implementation-dependent value is returned.
10969 def >=; true || false; end
10970 ##
10971 # <code>true</code> if <code>flt</code> is less than <code>real</code>.
10972 # The result of <code>NaN < NaN</code> is undefined, so the
10973 # implementation-dependent value is returned.
10974 def <; true || false; end
10975 ##
10976 # <code>true</code> if <code>flt</code> is less than
10977 # or equal to <code>real</code>.
10978 # The result of <code>NaN <= NaN</code> is undefined, so the
10979 # implementation-dependent value is returned.
10980 def <=; true || false; end
10981 ##
10982 # Returns <code>true</code> only if <i>obj</i> is a
10983 # <code>Float</code> with the same value as <i>flt</i>. Contrast this
10984 # with <code>Float#==</code>, which performs type conversions.
10985 # The result of <code>NaN.eql?(NaN)</code> is undefined, so the
10986 # implementation-dependent value is returned.
10987 # 
10988 #    1.0.eql?(1)   #=> false
10989 def eql?(obj); true || false; end
10990 ##
10991 # Returns a hash code for this float.
10992 def hash; 0; end
10993 ##
10994 # As <code>flt</code> is already a float, returns +self+.
10995 def to_f; self; end
10996 ##
10997 # Returns the absolute value of <i>flt</i>.
10998 # 
10999 #    (-34.56).abs   #=> 34.56
11000 #    -34.56.abs     #=> 34.56
11001 def abs; 0.0; end
11002 ##
11003 # Returns the absolute value of <i>flt</i>.
11004 # 
11005 #    (-34.56).abs   #=> 34.56
11006 #    -34.56.abs     #=> 34.56
11007 def magnitude; 0.0; end
11008 ##
11009 # Returns <code>true</code> if <i>flt</i> is 0.0.
11010 def zero?; true || false; end
11011 ##
11012 # Returns <i>flt</i> truncated to an <code>Integer</code>.
11013 def to_i; 0; end
11014 ##
11015 # Returns <i>flt</i> truncated to an <code>Integer</code>.
11016 def to_int; 0; end
11017 ##
11018 # Returns <i>flt</i> truncated to an <code>Integer</code>.
11019 def truncate; 0; end
11020 ##
11021 # Returns the largest integer less than or equal to <i>flt</i>.
11022 # 
11023 #    1.2.floor      #=> 1
11024 #    2.0.floor      #=> 2
11025 #    (-1.2).floor   #=> -2
11026 #    (-2.0).floor   #=> -2
11027 def floor; 0; end
11028 ##
11029 # Returns the smallest <code>Integer</code> greater than or equal to
11030 # <i>flt</i>.
11031 # 
11032 #    1.2.ceil      #=> 2
11033 #    2.0.ceil      #=> 2
11034 #    (-1.2).ceil   #=> -1
11035 #    (-2.0).ceil   #=> -2
11036 def ceil; 0; end
11037 ##
11038 # Rounds <i>flt</i> to a given precision in decimal digits (default 0 digits).
11039 # Precision may be negative.  Returns a floating point number when ndigits
11040 # is more than zero.
11041 # 
11042 #    1.4.round      #=> 1
11043 #    1.5.round      #=> 2
11044 #    1.6.round      #=> 2
11045 #    (-1.5).round   #=> -2
11046 # 
11047 #    1.234567.round(2)  #=> 1.23
11048 #    1.234567.round(3)  #=> 1.235
11049 #    1.234567.round(4)  #=> 1.2346
11050 #    1.234567.round(5)  #=> 1.23457
11051 # 
11052 #    34567.89.round(-5) #=> 0
11053 #    34567.89.round(-4) #=> 30000
11054 #    34567.89.round(-3) #=> 35000
11055 #    34567.89.round(-2) #=> 34600
11056 #    34567.89.round(-1) #=> 34570
11057 #    34567.89.round(0)  #=> 34568
11058 #    34567.89.round(1)  #=> 34567.9
11059 #    34567.89.round(2)  #=> 34567.89
11060 #    34567.89.round(3)  #=> 34567.89
11061 def round(ndigits=0); 0 || 0.0; end
11062 ##
11063 # Returns <code>true</code> if <i>flt</i> is an invalid IEEE floating
11064 # point number.
11065 # 
11066 #    a = -1.0      #=> -1.0
11067 #    a.nan?        #=> false
11068 #    a = 0.0/0.0   #=> NaN
11069 #    a.nan?        #=> true
11070 def nan?; true || false; end
11071 ##
11072 # Returns <code>nil</code>, -1, or +1 depending on whether <i>flt</i>
11073 # is finite, -infinity, or +infinity.
11074 # 
11075 #    (0.0).infinite?        #=> nil
11076 #    (-1.0/0.0).infinite?   #=> -1
11077 #    (+1.0/0.0).infinite?   #=> 1
11078 def infinite?; 1 || nil; end
11079 ##
11080 # Returns <code>true</code> if <i>flt</i> is a valid IEEE floating
11081 # point number (it is not infinite, and <code>nan?</code> is
11082 # <code>false</code>).
11083 def finite?; true || false; end
11084 ##
11085 # Returns 0 if the value is positive, pi otherwise.
11086 def arg; 0 || 0.0; end
11087 ##
11088 # Returns 0 if the value is positive, pi otherwise.
11089 def angle; 0 || 0.0; end
11090 ##
11091 # Returns 0 if the value is positive, pi otherwise.
11092 def phase; 0 || 0.0; end
11093 end
11094 
11095 class NilClass < Object
11096 ##
11097 # Returns zero as a rational.
11098 def to_r; (0/1); end
11099 ##
11100 # Returns zero as a rational.  The optional argument eps is always
11101 # ignored.
11102 def rationalize(eps=0); (0/1); end
11103 ##
11104 # Always returns zero.
11105 # 
11106 #    nil.to_i   #=> 0
11107 def to_i; 0; end
11108 ##
11109 # Always returns zero.
11110 # 
11111 #    nil.to_f   #=> 0.0
11112 def to_f; 0.0; end
11113 ##
11114 # Always returns the empty string.
11115 def to_s; ''; end
11116 ##
11117 # Always returns an empty array.
11118 # 
11119 #    nil.to_a   #=> []
11120 def to_a; end
11121 ##
11122 # Always returns an empty hash.
11123 # 
11124 #    nil.to_h   #=> {}
11125 def to_h; {}; end
11126 ##
11127 # Always returns the string "nil".
11128 def inspect; end
11129 ##
11130 # And---Returns <code>false</code>. <i>obj</i> is always
11131 # evaluated as it is the argument to a method call---there is no
11132 # short-circuit evaluation in this case.
11133 def &; false; end
11134 ##
11135 # Or---Returns <code>false</code> if <i>obj</i> is
11136 # <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
11137 def |; true || false; end
11138 ##
11139 # Exclusive Or---If <i>obj</i> is <code>nil</code> or
11140 # <code>false</code>, returns <code>false</code>; otherwise, returns
11141 # <code>true</code>.
11142 def ^; true || false; end
11143 ##
11144 # Returns zero as a complex.
11145 def to_c; Complex.new; end
11146 end
11147 
11148 ##
11149 # Random provides an interface to Ruby's pseudo-random number generator, or
11150 # PRNG.  The PRNG produces a deterministic sequence of bits which approximate
11151 # true randomness. The sequence may be represented by integers, floats, or
11152 # binary strings.
11153 # 
11154 # The generator may be initialized with either a system-generated or
11155 # user-supplied seed value by using Random.srand.
11156 # 
11157 # The class method Random.rand provides the base functionality of Kernel.rand
11158 # along with better handling of floating point values. These are both
11159 # interfaces to Random::DEFAULT, the Ruby system PRNG.
11160 # 
11161 # Random.new will create a new PRNG with a state independent of
11162 # Random::DEFAULT, allowing multiple generators with different seed values or
11163 # sequence positions to exist simultaneously. Random objects can be
11164 # marshaled, allowing sequences to be saved and resumed.
11165 # 
11166 # PRNGs are currently implemented as a modified Mersenne Twister with a period
11167 # of 2**19937-1.
11168 class Random < Object
11169 ##
11170 # Creates a new PRNG using +seed+ to set the initial state. If +seed+ is
11171 # omitted, the generator is initialized with Random.new_seed.
11172 # 
11173 # See Random.srand for more information on the use of seed values.
11174 def self.new(seed = Random.new_seed); end
11175 ##
11176 # When +max+ is an Integer, +rand+ returns a random integer greater than
11177 # or equal to zero and less than +max+. Unlike Kernel.rand, when +max+
11178 # is a negative integer or zero, +rand+ raises an ArgumentError.
11179 # 
11180 #   prng = Random.new
11181 #   prng.rand(100)       # => 42
11182 # 
11183 # When +max+ is a Float, +rand+ returns a random floating point number
11184 # between 0.0 and +max+, including 0.0 and excluding +max+.
11185 # 
11186 #   prng.rand(1.5)       # => 1.4600282860034115
11187 # 
11188 # When +max+ is a Range, +rand+ returns a random number where
11189 # range.member?(number) == true.
11190 # 
11191 #   prng.rand(5..9)      # => one of [5, 6, 7, 8, 9]
11192 #   prng.rand(5...9)     # => one of [5, 6, 7, 8]
11193 #   prng.rand(5.0..9.0)  # => between 5.0 and 9.0, including 9.0
11194 #   prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0
11195 # 
11196 # Both the beginning and ending values of the range must respond to subtract
11197 # (<tt>-</tt>) and add (<tt>+</tt>)methods, or rand will raise an
11198 # ArgumentError.
11199 def rand(max); 0; end
11200 ##
11201 # Returns a random binary string containing +size+ bytes.
11202 # 
11203 #   random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO"
11204 #   random_string.size                   # => 10
11205 def bytes(size); ''; end
11206 ##
11207 # Returns the seed value used to initialize the generator. This may be used to
11208 # initialize another generator with the same state at a later time, causing it
11209 # to produce the same sequence of numbers.
11210 # 
11211 #   prng1 = Random.new(1234)
11212 #   prng1.seed       #=> 1234
11213 #   prng1.rand(100)  #=> 47
11214 # 
11215 #   prng2 = Random.new(prng1.seed)
11216 #   prng2.rand(100)  #=> 47
11217 def seed; 0; end
11218 ##
11219 # Returns true if the two generators have the same internal state, otherwise
11220 # false.  Equivalent generators will return the same sequence of
11221 # pseudo-random numbers.  Two generators will generally have the same state
11222 # only if they were initialized with the same seed
11223 # 
11224 #   Random.new == Random.new             # => false
11225 #   Random.new(1234) == Random.new(1234) # => true
11226 # 
11227 # and have the same invocation history.
11228 # 
11229 #   prng1 = Random.new(1234)
11230 #   prng2 = Random.new(1234)
11231 #   prng1 == prng2 # => true
11232 # 
11233 #   prng1.rand     # => 0.1915194503788923
11234 #   prng1 == prng2 # => false
11235 # 
11236 #   prng2.rand     # => 0.1915194503788923
11237 #   prng1 == prng2 # => true
11238 def ==; true || false; end
11239 ##
11240 # Seeds the system pseudo-random number generator, Random::DEFAULT, with
11241 # +number+.  The previous seed value is returned.
11242 # 
11243 # If +number+ is omitted, seeds the generator using a source of entropy
11244 # provided by the operating system, if available (/dev/urandom on Unix systems
11245 # or the RSA cryptographic provider on Windows), which is then combined with
11246 # the time, the process id, and a sequence number.
11247 # 
11248 # srand may be used to ensure repeatable sequences of pseudo-random numbers
11249 # between different runs of the program. By setting the seed to a known value,
11250 # programs can be made deterministic during testing.
11251 # 
11252 #   srand 1234               # => 268519324636777531569100071560086917274
11253 #   [ rand, rand ]           # => [0.1915194503788923, 0.6221087710398319]
11254 #   [ rand(10), rand(1000) ] # => [4, 664]
11255 #   srand 1234               # => 1234
11256 #   [ rand, rand ]           # => [0.1915194503788923, 0.6221087710398319]
11257 def self.srand(number = Random.new_seed); 1; end
11258 ##
11259 # Returns an arbitrary seed value. This is used by Random.new
11260 # when no seed value is specified as an argument.
11261 # 
11262 #   Random.new_seed  #=> 115032730400174366788466674494640623225
11263 def self.new_seed; 0; end
11264 end
11265 
11266 class BasicObject
11267 ##
11268 # Evaluates a string containing Ruby source code, or the given block,
11269 # within the context of the receiver (_obj_). In order to set the
11270 # context, the variable +self+ is set to _obj_ while
11271 # the code is executing, giving the code access to _obj_'s
11272 # instance variables. In the version of <code>instance_eval</code>
11273 # that takes a +String+, the optional second and third
11274 # parameters supply a filename and starting line number that are used
11275 # when reporting compilation errors.
11276 # 
11277 #    class KlassWithSecret
11278 #      def initialize
11279 #        @secret = 99
11280 #      end
11281 #    end
11282 #    k = KlassWithSecret.new
11283 #    k.instance_eval { @secret }   #=> 99
11284 def instance_eval(string  , filename=0, lineno=0); Object.new; end
11285 ##
11286 # Executes the given block within the context of the receiver
11287 # (_obj_). In order to set the context, the variable +self+ is set
11288 # to _obj_ while the code is executing, giving the code access to
11289 # _obj_'s instance variables.  Arguments are passed as block parameters.
11290 # 
11291 #    class KlassWithSecret
11292 #      def initialize
11293 #        @secret = 99
11294 #      end
11295 #    end
11296 #    k = KlassWithSecret.new
11297 #    k.instance_exec(5) {|x| @secret+x }   #=> 104
11298 def instance_exec(&block); Object.new; end
11299 ##
11300 # Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
11301 # <i>symbol</i> is the symbol for the method called, and <i>args</i>
11302 # are any arguments that were passed to it. By default, the interpreter
11303 # raises an error when this method is called. However, it is possible
11304 # to override the method to provide more dynamic behavior.
11305 # If it is decided that a particular method should not be handled, then
11306 # <i>super</i> should be called, so that ancestors can pick up the
11307 # missing method.
11308 # The example below creates
11309 # a class <code>Roman</code>, which responds to methods with names
11310 # consisting of roman numerals, returning the corresponding integer
11311 # values.
11312 # 
11313 #    class Roman
11314 #      def roman_to_int(str)
11315 #        # ...
11316 #      end
11317 #      def method_missing(methId)
11318 #        str = methId.id2name
11319 #        roman_to_int(str)
11320 #      end
11321 #    end
11322 # 
11323 #    r = Roman.new
11324 #    r.iv      #=> 4
11325 #    r.xxiii   #=> 23
11326 #    r.mm      #=> 2000
11327 def method_missing(symbol  , args=0); Object.new; end
11328 ##
11329 # Invokes the method identified by _symbol_, passing it any
11330 # arguments specified. You can use <code>__send__</code> if the name
11331 # +send+ clashes with an existing method in _obj_.
11332 # When the method is identified by a string, the string is converted
11333 # to a symbol.
11334 # 
11335 #    class Klass
11336 #      def hello(*args)
11337 #        "Hello " + args.join(' ')
11338 #      end
11339 #    end
11340 #    k = Klass.new
11341 #    k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"
11342 def send(symbol , args=0); Object.new; end
11343 ##
11344 # Invokes the method identified by _symbol_, passing it any
11345 # arguments specified. You can use <code>__send__</code> if the name
11346 # +send+ clashes with an existing method in _obj_.
11347 # When the method is identified by a string, the string is converted
11348 # to a symbol.
11349 # 
11350 #    class Klass
11351 #      def hello(*args)
11352 #        "Hello " + args.join(' ')
11353 #      end
11354 #    end
11355 #    k = Klass.new
11356 #    k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"
11357 def __send__(symbol , args=0); Object.new; end
11358 ##
11359 # Returns an integer identifier for +obj+.
11360 # 
11361 # The same number will be returned on all calls to +id+ for a given object,
11362 # and no two active objects will share an id.
11363 # 
11364 # Object#object_id is a different concept from the +:name+ notation, which
11365 # returns the symbol id of +name+.
11366 # 
11367 # Replaces the deprecated Object#id.
11368 def __id__; 0; end
11369 ##
11370 # Returns an integer identifier for +obj+.
11371 # 
11372 # The same number will be returned on all calls to +id+ for a given object,
11373 # and no two active objects will share an id.
11374 # 
11375 # Object#object_id is a different concept from the +:name+ notation, which
11376 # returns the symbol id of +name+.
11377 # 
11378 # Replaces the deprecated Object#id.
11379 def object_id; 0; end
11380 ##
11381 # Equality --- At the <code>Object</code> level, <code>==</code> returns
11382 # <code>true</code> only if +obj+ and +other+ are the same object.
11383 # Typically, this method is overridden in descendant classes to provide
11384 # class-specific meaning.
11385 # 
11386 # Unlike <code>==</code>, the <code>equal?</code> method should never be
11387 # overridden by subclasses as it is used to determine object identity
11388 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
11389 # same object as <code>b</code>):
11390 # 
11391 #   obj = "a"
11392 #   other = obj.dup
11393 # 
11394 #   a == other      #=> true
11395 #   a.equal? other  #=> false
11396 #   a.equal? a      #=> true
11397 # 
11398 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
11399 # +other+ refer to the same hash key.  This is used by Hash to test members
11400 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
11401 # is synonymous with <code>==</code>.  Subclasses normally continue this
11402 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
11403 # method, but there are exceptions.  <code>Numeric</code> types, for
11404 # example, perform type conversion across <code>==</code>, but not across
11405 # <code>eql?</code>, so:
11406 # 
11407 #    1 == 1.0     #=> true
11408 #    1.eql? 1.0   #=> false
11409 def ==; true || false; end
11410 ##
11411 # Equality --- At the <code>Object</code> level, <code>==</code> returns
11412 # <code>true</code> only if +obj+ and +other+ are the same object.
11413 # Typically, this method is overridden in descendant classes to provide
11414 # class-specific meaning.
11415 # 
11416 # Unlike <code>==</code>, the <code>equal?</code> method should never be
11417 # overridden by subclasses as it is used to determine object identity
11418 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
11419 # same object as <code>b</code>):
11420 # 
11421 #   obj = "a"
11422 #   other = obj.dup
11423 # 
11424 #   a == other      #=> true
11425 #   a.equal? other  #=> false
11426 #   a.equal? a      #=> true
11427 # 
11428 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
11429 # +other+ refer to the same hash key.  This is used by Hash to test members
11430 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
11431 # is synonymous with <code>==</code>.  Subclasses normally continue this
11432 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
11433 # method, but there are exceptions.  <code>Numeric</code> types, for
11434 # example, perform type conversion across <code>==</code>, but not across
11435 # <code>eql?</code>, so:
11436 # 
11437 #    1 == 1.0     #=> true
11438 #    1.eql? 1.0   #=> false
11439 def equal?(other); true || false; end
11440 ##
11441 # Equality --- At the <code>Object</code> level, <code>==</code> returns
11442 # <code>true</code> only if +obj+ and +other+ are the same object.
11443 # Typically, this method is overridden in descendant classes to provide
11444 # class-specific meaning.
11445 # 
11446 # Unlike <code>==</code>, the <code>equal?</code> method should never be
11447 # overridden by subclasses as it is used to determine object identity
11448 # (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the
11449 # same object as <code>b</code>):
11450 # 
11451 #   obj = "a"
11452 #   other = obj.dup
11453 # 
11454 #   a == other      #=> true
11455 #   a.equal? other  #=> false
11456 #   a.equal? a      #=> true
11457 # 
11458 # The <code>eql?</code> method returns <code>true</code> if +obj+ and
11459 # +other+ refer to the same hash key.  This is used by Hash to test members
11460 # for equality.  For objects of class <code>Object</code>, <code>eql?</code>
11461 # is synonymous with <code>==</code>.  Subclasses normally continue this
11462 # tradition by aliasing <code>eql?</code> to their overridden <code>==</code>
11463 # method, but there are exceptions.  <code>Numeric</code> types, for
11464 # example, perform type conversion across <code>==</code>, but not across
11465 # <code>eql?</code>, so:
11466 # 
11467 #    1 == 1.0     #=> true
11468 #    1.eql? 1.0   #=> false
11469 def eql?(other); true || false; end
11470 ##
11471 # Boolean negate.
11472 def !; true || false; end
11473 ##
11474 # Returns true if two objects are not-equal, otherwise false.
11475 def !=; true || false; end
11476 ##
11477 # Invoked as a callback whenever a singleton method is added to the
11478 # receiver.
11479 # 
11480 #    module Chatty
11481 #      def Chatty.singleton_method_added(id)
11482 #        puts "Adding #{id.id2name}"
11483 #      end
11484 #      def self.one()     end
11485 #      def two()          end
11486 #      def Chatty.three() end
11487 #    end
11488 # 
11489 # <em>produces:</em>
11490 # 
11491 #    Adding singleton_method_added
11492 #    Adding one
11493 #    Adding three
11494 def singleton_method_added(symbol); end
11495 ##
11496 # Invoked as a callback whenever a singleton method is removed from
11497 # the receiver.
11498 # 
11499 #    module Chatty
11500 #      def Chatty.singleton_method_removed(id)
11501 #        puts "Removing #{id.id2name}"
11502 #      end
11503 #      def self.one()     end
11504 #      def two()          end
11505 #      def Chatty.three() end
11506 #      class << self
11507 #        remove_method :three
11508 #        remove_method :one
11509 #      end
11510 #    end
11511 # 
11512 # <em>produces:</em>
11513 # 
11514 #    Removing three
11515 #    Removing one
11516 def singleton_method_removed(symbol); end
11517 ##
11518 # Invoked as a callback whenever a singleton method is undefined in
11519 # the receiver.
11520 # 
11521 #    module Chatty
11522 #      def Chatty.singleton_method_undefined(id)
11523 #        puts "Undefining #{id.id2name}"
11524 #      end
11525 #      def Chatty.one()   end
11526 #      class << self
11527 #         undef_method(:one)
11528 #      end
11529 #    end
11530 # 
11531 # <em>produces:</em>
11532 # 
11533 #    Undefining one
11534 def singleton_method_undefined(symbol); end
11535 end
11536 
11537 ##
11538 # An Encoding instance represents a character encoding usable in Ruby. It is
11539 # defined as a constant under the Encoding namespace. It has a name and
11540 # optionally, aliases:
11541 # 
11542 #   Encoding::ISO_8859_1.name
11543 #   #=> #<Encoding:ISO-8859-1>
11544 # 
11545 #   Encoding::ISO_8859_1.names
11546 #   #=> ["ISO-8859-1", "ISO8859-1"]
11547 # 
11548 # Ruby methods dealing with encodings return or accept Encoding instances as
11549 # arguments (when a method accepts an Encoding instance as an argument, it
11550 # can be passed an Encoding name or alias instead).
11551 # 
11552 #   "some string".encoding
11553 #   #=> #<Encoding:UTF-8>
11554 # 
11555 #   string = "some string".encode(Encoding::ISO_8859_1)
11556 #   #=> "some string"
11557 #   string.encoding
11558 #   #=> #<Encoding:ISO-8859-1>
11559 # 
11560 #   "some string".encode "ISO-8859-1"
11561 #   #=> "some string"
11562 # 
11563 # <code>Encoding::ASCII_8BIT</code> is a special encoding that is usually
11564 # used for a byte string, not a character string. But as the name insists,
11565 # its characters in the range of ASCII are considered as ASCII characters.
11566 # This is useful when you use ASCII-8BIT characters with other ASCII
11567 # compatible characters.
11568 # 
11569 # == Changing an encoding
11570 # 
11571 # The associated Encoding of a String can be changed in two different ways.
11572 # 
11573 # First, it is possible to set the Encoding of a string to a new Encoding
11574 # without changing the internal byte representation of the string, with
11575 # String#force_encoding. This is how you can tell Ruby the correct encoding
11576 # of a string.
11577 # 
11578 #   string
11579 #   #=> "R\xC3\xA9sum\xC3\xA9"
11580 #   string.encoding
11581 #   #=> #<Encoding:ISO-8859-1>
11582 #   string.force_encoding(Encoding::UTF_8)
11583 #   #=> "R\u00E9sum\u00E9"
11584 # 
11585 # Second, it is possible to transcode a string, i.e. translate its internal
11586 # byte representation to another encoding. Its associated encoding is also
11587 # set to the other encoding. See String#encode for the various forms of
11588 # transcoding, and the Encoding::Converter class for additional control over
11589 # the transcoding process.
11590 # 
11591 #   string
11592 #   #=> "R\u00E9sum\u00E9"
11593 #   string.encoding
11594 #   #=> #<Encoding:UTF-8>
11595 #   string = string.encode!(Encoding::ISO_8859_1)
11596 #   #=> "R\xE9sum\xE9"
11597 #   string.encoding
11598 #   #=> #<Encoding::ISO-8859-1>
11599 # 
11600 # == Script encoding
11601 # 
11602 # All Ruby script code has an associated Encoding which any String literal
11603 # created in the source code will be associated to.
11604 # 
11605 # The default script encoding is <code>Encoding::US-ASCII</code>, but it can
11606 # be changed by a magic comment on the first line of the source code file (or
11607 # second line, if there is a shebang line on the first). The comment must
11608 # contain the word <code>coding</code> or <code>encoding</code>, followed
11609 # by a colon, space and the Encoding name or alias:
11610 # 
11611 #   # encoding: UTF-8
11612 # 
11613 #   "some string".encoding
11614 #   #=> #<Encoding:UTF-8>
11615 # 
11616 # The <code>__ENCODING__</code> keyword returns the script encoding of the file
11617 # which the keyword is written:
11618 # 
11619 #   # encoding: ISO-8859-1
11620 # 
11621 #   __ENCODING__
11622 #   #=> #<Encoding:ISO-8859-1>
11623 # 
11624 # <code>ruby -K</code> will change the default locale encoding, but this is
11625 # not recommended. Ruby source files should declare its script encoding by a
11626 # magic comment even when they only depend on US-ASCII strings or regular
11627 # expressions.
11628 # 
11629 # == Locale encoding
11630 # 
11631 # The default encoding of the environment. Usually derived from locale.
11632 # 
11633 # see Encoding.locale_charmap, Encoding.find('locale')
11634 # 
11635 # == Filesystem encoding
11636 # 
11637 # The default encoding of strings from the filesystem of the environment.
11638 # This is used for strings of file names or paths.
11639 # 
11640 # see Encoding.find('filesystem')
11641 # 
11642 # == External encoding
11643 # 
11644 # Each IO object has an external encoding which indicates the encoding that
11645 # Ruby will use to read its data. By default Ruby sets the external encoding
11646 # of an IO object to the default external encoding. The default external
11647 # encoding is set by locale encoding or the interpreter <code>-E</code> option.
11648 # Encoding.default_external returns the current value of the external
11649 # encoding.
11650 # 
11651 #   ENV["LANG"]
11652 #   #=> "UTF-8"
11653 #   Encoding.default_external
11654 #   #=> #<Encoding:UTF-8>
11655 # 
11656 #   $ ruby -E ISO-8859-1 -e "p Encoding.default_external"
11657 #   #<Encoding:ISO-8859-1>
11658 # 
11659 #   $ LANG=C ruby -e 'p Encoding.default_external'
11660 #   #<Encoding:US-ASCII>
11661 # 
11662 # The default external encoding may also be set through
11663 # Encoding.default_external=, but you should not do this as strings created
11664 # before and after the change will have inconsistent encodings.  Instead use
11665 # <code>ruby -E</code> to invoke ruby with the correct external encoding.
11666 # 
11667 # When you know that the actual encoding of the data of an IO object is not
11668 # the default external encoding, you can reset its external encoding with
11669 # IO#set_encoding or set it at IO object creation (see IO.new options).
11670 # 
11671 # == Internal encoding
11672 # 
11673 # To process the data of an IO object which has an encoding different
11674 # from its external encoding, you can set its internal encoding. Ruby will use
11675 # this internal encoding to transcode the data when it is read from the IO
11676 # object.
11677 # 
11678 # Conversely, when data is written to the IO object it is transcoded from the
11679 # internal encoding to the external encoding of the IO object.
11680 # 
11681 # The internal encoding of an IO object can be set with
11682 # IO#set_encoding or at IO object creation (see IO.new options).
11683 # 
11684 # The internal encoding is optional and when not set, the Ruby default
11685 # internal encoding is used. If not explicitly set this default internal
11686 # encoding is +nil+ meaning that by default, no transcoding occurs.
11687 # 
11688 # The default internal encoding can be set with the interpreter option
11689 # <code>-E</code>. Encoding.default_internal returns the current internal
11690 # encoding.
11691 # 
11692 #    $ ruby -e 'p Encoding.default_internal'
11693 #    nil
11694 # 
11695 #    $ ruby -E ISO-8859-1:UTF-8 -e "p [Encoding.default_external, \
11696 #      Encoding.default_internal]"
11697 #    [#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>]
11698 # 
11699 # The default internal encoding may also be set through
11700 # Encoding.default_internal=, but you should not do this as strings created
11701 # before and after the change will have inconsistent encodings.  Instead use
11702 # <code>ruby -E</code> to invoke ruby with the correct internal encoding.
11703 # 
11704 # == IO encoding example
11705 # 
11706 # In the following example a UTF-8 encoded string "R\u00E9sum\u00E9" is transcoded for
11707 # output to ISO-8859-1 encoding, then read back in and transcoded to UTF-8:
11708 # 
11709 #   string = "R\u00E9sum\u00E9"
11710 # 
11711 #   open("transcoded.txt", "w:ISO-8859-1") do |io|
11712 #     io.write(string)
11713 #   end
11714 # 
11715 #   puts "raw text:"
11716 #   p File.binread("transcoded.txt")
11717 #   puts
11718 # 
11719 #   open("transcoded.txt", "r:ISO-8859-1:UTF-8") do |io|
11720 #     puts "transcoded text:"
11721 #     p io.read
11722 #   end
11723 # 
11724 # While writing the file, the internal encoding is not specified as it is
11725 # only necessary for reading.  While reading the file both the internal and
11726 # external encoding must be specified to obtain the correct result.
11727 # 
11728 #   $ ruby t.rb
11729 #   raw text:
11730 #   "R\xE9sum\xE9"
11731 # 
11732 #   transcoded text:
11733 #   "R\u00E9sum\u00E9"
11734 class Encoding < Object
11735 ##
11736 # Raised by Encoding and String methods when the source encoding is
11737 # incompatible with the target encoding.
11738 class CompatibilityError < EncodingError
11739 end
11740 
11741 ##
11742 # Raised by Encoding and String methods when a transcoding operation
11743 # fails.
11744 class UndefinedConversionError < rb_eEncodingError
11745 ##
11746 # Returns the source encoding name as a string.
11747 def source_encoding_name; ''; end
11748 ##
11749 # Returns the destination encoding name as a string.
11750 def destination_encoding_name; ''; end
11751 ##
11752 # Returns the source encoding as an encoding object.
11753 # 
11754 # Note that the result may not be equal to the source encoding of
11755 # the encoding converter if the conversion has multiple steps.
11756 # 
11757 #  ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
11758 #  begin
11759 #    ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
11760 #  rescue Encoding::UndefinedConversionError
11761 #    p $!.source_encoding              #=> #<Encoding:UTF-8>
11762 #    p $!.destination_encoding         #=> #<Encoding:EUC-JP>
11763 #    p $!.source_encoding_name         #=> "UTF-8"
11764 #    p $!.destination_encoding_name    #=> "EUC-JP"
11765 #  end
11766 def source_encoding; Encoding.new; end
11767 ##
11768 # Returns the destination encoding as an encoding object.
11769 def destination_encoding; ''; end
11770 ##
11771 # Returns the one-character string which cause Encoding::UndefinedConversionError.
11772 # 
11773 #  ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP")
11774 #  begin
11775 #    ec.convert("\xa0")
11776 #  rescue Encoding::UndefinedConversionError
11777 #    puts $!.error_char.dump   #=> "\xC2\xA0"
11778 #    p $!.error_char.encoding  #=> #<Encoding:UTF-8>
11779 #  end
11780 def error_char; ''; end
11781 end
11782 
11783 ##
11784 # Raised by Encoding and String methods when the string being
11785 # transcoded contains a byte invalid for the either the source or
11786 # target encoding.
11787 class InvalidByteSequenceError < rb_eEncodingError
11788 ##
11789 # Returns the source encoding name as a string.
11790 def source_encoding_name; ''; end
11791 ##
11792 # Returns the destination encoding name as a string.
11793 def destination_encoding_name; ''; end
11794 ##
11795 # Returns the source encoding as an encoding object.
11796 # 
11797 # Note that the result may not be equal to the source encoding of
11798 # the encoding converter if the conversion has multiple steps.
11799 # 
11800 #  ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP") # ISO-8859-1 -> UTF-8 -> EUC-JP
11801 #  begin
11802 #    ec.convert("\xa0") # NO-BREAK SPACE, which is available in UTF-8 but not in EUC-JP.
11803 #  rescue Encoding::UndefinedConversionError
11804 #    p $!.source_encoding              #=> #<Encoding:UTF-8>
11805 #    p $!.destination_encoding         #=> #<Encoding:EUC-JP>
11806 #    p $!.source_encoding_name         #=> "UTF-8"
11807 #    p $!.destination_encoding_name    #=> "EUC-JP"
11808 #  end
11809 def source_encoding; Encoding.new; end
11810 ##
11811 # Returns the destination encoding as an encoding object.
11812 def destination_encoding; ''; end
11813 ##
11814 # Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs.
11815 # 
11816 #  ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
11817 #  begin
11818 #    ec.convert("abc\xA1\xFFdef")
11819 #  rescue Encoding::InvalidByteSequenceError
11820 #    p $!      #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
11821 #    puts $!.error_bytes.dump          #=> "\xA1"
11822 #    puts $!.readagain_bytes.dump      #=> "\xFF"
11823 #  end
11824 def error_bytes; ''; end
11825 ##
11826 # Returns the bytes to be read again when Encoding::InvalidByteSequenceError occurs.
11827 def readagain_bytes; ''; end
11828 ##
11829 # Returns true if the invalid byte sequence error is caused by
11830 # premature end of string.
11831 # 
11832 #  ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
11833 # 
11834 #  begin
11835 #    ec.convert("abc\xA1z")
11836 #  rescue Encoding::InvalidByteSequenceError
11837 #    p $!      #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP>
11838 #    p $!.incomplete_input?    #=> false
11839 #  end
11840 # 
11841 #  begin
11842 #    ec.convert("abc\xA1")
11843 #    ec.finish
11844 #  rescue Encoding::InvalidByteSequenceError
11845 #    p $!      #=> #<Encoding::InvalidByteSequenceError: incomplete "\xA1" on EUC-JP>
11846 #    p $!.incomplete_input?    #=> true
11847 #  end
11848 def incomplete_input?; true || false; end
11849 end
11850 
11851 ##
11852 # Raised by transcoding methods when a named encoding does not
11853 # correspond with a known converter.
11854 class ConverterNotFoundError < rb_eEncodingError
11855 end
11856 
11857 class Converter < Data
11858 ##
11859 # Returns the corresponding ASCII compatible encoding.
11860 # 
11861 # Returns nil if the argument is an ASCII compatible encoding.
11862 # 
11863 # "corresponding ASCII compatible encoding" is an ASCII compatible encoding which
11864 # can represents exactly the same characters as the given ASCII incompatible encoding.
11865 # So, no conversion undefined error occurs when converting between the two encodings.
11866 # 
11867 #   Encoding::Converter.asciicompat_encoding("ISO-2022-JP") #=> #<Encoding:stateless-ISO-2022-JP>
11868 #   Encoding::Converter.asciicompat_encoding("UTF-16BE") #=> #<Encoding:UTF-8>
11869 #   Encoding::Converter.asciicompat_encoding("UTF-8") #=> nil
11870 def self.asciicompat_encoding(string); Encoding.new || nil; end
11871 ##
11872 # Returns a conversion path.
11873 # 
11874 #  p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP")
11875 #  #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
11876 #  #    [#<Encoding:UTF-8>, #<Encoding:EUC-JP>]]
11877 # 
11878 #  p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", universal_newline: true)
11879 #  or
11880 #  p Encoding::Converter.search_convpath("ISO-8859-1", "EUC-JP", newline: :universal)
11881 #  #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
11882 #  #    [#<Encoding:UTF-8>, #<Encoding:EUC-JP>],
11883 #  #    "universal_newline"]
11884 # 
11885 #  p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", universal_newline: true)
11886 #  or
11887 #  p Encoding::Converter.search_convpath("ISO-8859-1", "UTF-32BE", newline: :universal)
11888 #  #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
11889 #  #    "universal_newline",
11890 #  #    [#<Encoding:UTF-8>, #<Encoding:UTF-32BE>]]
11891 def self.search_convpath(source_encoding, destination_encoding); []; end
11892 ##
11893 # possible options elements:
11894 #   hash form:
11895 #     :invalid => nil            # raise error on invalid byte sequence (default)
11896 #     :invalid => :replace       # replace invalid byte sequence
11897 #     :undef => nil              # raise error on undefined conversion (default)
11898 #     :undef => :replace         # replace undefined conversion
11899 #     :replace => string         # replacement string ("?" or "\uFFFD" if not specified)
11900 #     :newline => :universal     # decorator for converting CRLF and CR to LF
11901 #     :newline => :crlf          # decorator for converting LF to CRLF
11902 #     :newline => :cr            # decorator for converting LF to CR
11903 #     :universal_newline => true # decorator for converting CRLF and CR to LF
11904 #     :crlf_newline => true      # decorator for converting LF to CRLF
11905 #     :cr_newline => true        # decorator for converting LF to CR
11906 #     :xml => :text              # escape as XML CharData.
11907 #     :xml => :attr              # escape as XML AttValue
11908 #   integer form:
11909 #     Encoding::Converter::INVALID_REPLACE
11910 #     Encoding::Converter::UNDEF_REPLACE
11911 #     Encoding::Converter::UNDEF_HEX_CHARREF
11912 #     Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR
11913 #     Encoding::Converter::CRLF_NEWLINE_DECORATOR
11914 #     Encoding::Converter::CR_NEWLINE_DECORATOR
11915 #     Encoding::Converter::XML_TEXT_DECORATOR
11916 #     Encoding::Converter::XML_ATTR_CONTENT_DECORATOR
11917 #     Encoding::Converter::XML_ATTR_QUOTE_DECORATOR
11918 # 
11919 # Encoding::Converter.new creates an instance of Encoding::Converter.
11920 # 
11921 # Source_encoding and destination_encoding should be a string or
11922 # Encoding object.
11923 # 
11924 # opt should be nil, a hash or an integer.
11925 # 
11926 # convpath should be an array.
11927 # convpath may contain
11928 # - two-element arrays which contain encodings or encoding names, or
11929 # - strings representing decorator names.
11930 # 
11931 # Encoding::Converter.new optionally takes an option.
11932 # The option should be a hash or an integer.
11933 # The option hash can contain :invalid => nil, etc.
11934 # The option integer should be logical-or of constants such as
11935 # Encoding::Converter::INVALID_REPLACE, etc.
11936 # 
11937 # [:invalid => nil]
11938 #   Raise error on invalid byte sequence.  This is a default behavior.
11939 # [:invalid => :replace]
11940 #   Replace invalid byte sequence by replacement string.
11941 # [:undef => nil]
11942 #   Raise an error if a character in source_encoding is not defined in destination_encoding.
11943 #   This is a default behavior.
11944 # [:undef => :replace]
11945 #   Replace undefined character in destination_encoding with replacement string.
11946 # [:replace => string]
11947 #   Specify the replacement string.
11948 #   If not specified, "\uFFFD" is used for Unicode encodings and "?" for others.
11949 # [:universal_newline => true]
11950 #   Convert CRLF and CR to LF.
11951 # [:crlf_newline => true]
11952 #   Convert LF to CRLF.
11953 # [:cr_newline => true]
11954 #   Convert LF to CR.
11955 # [:xml => :text]
11956 #   Escape as XML CharData.
11957 #   This form can be used as a HTML 4.0 #PCDATA.
11958 #   - '&' -> '&amp;'
11959 #   - '<' -> '&lt;'
11960 #   - '>' -> '&gt;'
11961 #   - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH;
11962 # [:xml => :attr]
11963 #   Escape as XML AttValue.
11964 #   The converted result is quoted as "...".
11965 #   This form can be used as a HTML 4.0 attribute value.
11966 #   - '&' -> '&amp;'
11967 #   - '<' -> '&lt;'
11968 #   - '>' -> '&gt;'
11969 #   - '"' -> '&quot;'
11970 #   - undefined characters in destination_encoding -> hexadecimal CharRef such as &#xHH;
11971 # 
11972 # Examples:
11973 #   # UTF-16BE to UTF-8
11974 #   ec = Encoding::Converter.new("UTF-16BE", "UTF-8")
11975 # 
11976 #   # Usually, decorators such as newline conversion are inserted last.
11977 #   ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true)
11978 #   p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>],
11979 #                 #    "universal_newline"]
11980 # 
11981 #   # But, if the last encoding is ASCII incompatible,
11982 #   # decorators are inserted before the last conversion.
11983 #   ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true)
11984 #   p ec.convpath #=> ["crlf_newline",
11985 #                 #    [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
11986 # 
11987 #   # Conversion path can be specified directly.
11988 #   ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]])
11989 #   p ec.convpath #=> ["universal_newline",
11990 #                 #    [#<Encoding:EUC-JP>, #<Encoding:UTF-8>],
11991 #                 #    [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
11992 def self.new(source_encoding, destination_encoding); end
11993 ##
11994 # Returns a printable version of <i>ec</i>
11995 # 
11996 #   ec = Encoding::Converter.new("iso-8859-1", "utf-8")
11997 #   puts ec.inspect    #=> #<Encoding::Converter: ISO-8859-1 to UTF-8>
11998 def inspect; ''; end
11999 ##
12000 # Returns the conversion path of ec.
12001 # 
12002 # The result is an array of conversions.
12003 # 
12004 #   ec = Encoding::Converter.new("ISO-8859-1", "EUC-JP", crlf_newline: true)
12005 #   p ec.convpath
12006 #   #=> [[#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>],
12007 #   #    [#<Encoding:UTF-8>, #<Encoding:EUC-JP>],
12008 #   #    "crlf_newline"]
12009 # 
12010 # Each element of the array is a pair of encodings or a string.
12011 # A pair means an encoding conversion.
12012 # A string means a decorator.
12013 # 
12014 # In the above example, [#<Encoding:ISO-8859-1>, #<Encoding:UTF-8>] means
12015 # a converter from ISO-8859-1 to UTF-8.
12016 # "crlf_newline" means newline converter from LF to CRLF.
12017 def convpath; []; end
12018 ##
12019 # Returns the source encoding as an Encoding object.
12020 def source_encoding; Encoding.new; end
12021 ##
12022 # Returns the destination encoding as an Encoding object.
12023 def destination_encoding; Encoding.new; end
12024 ##
12025 # possible opt elements:
12026 #   hash form:
12027 #     :partial_input => true           # source buffer may be part of larger source
12028 #     :after_output => true            # stop conversion after output before input
12029 #   integer form:
12030 #     Encoding::Converter::PARTIAL_INPUT
12031 #     Encoding::Converter::AFTER_OUTPUT
12032 # 
12033 # possible results:
12034 #    :invalid_byte_sequence
12035 #    :incomplete_input
12036 #    :undefined_conversion
12037 #    :after_output
12038 #    :destination_buffer_full
12039 #    :source_buffer_empty
12040 #    :finished
12041 # 
12042 # primitive_convert converts source_buffer into destination_buffer.
12043 # 
12044 # source_buffer should be a string or nil.
12045 # nil means an empty string.
12046 # 
12047 # destination_buffer should be a string.
12048 # 
12049 # destination_byteoffset should be an integer or nil.
12050 # nil means the end of destination_buffer.
12051 # If it is omitted, nil is assumed.
12052 # 
12053 # destination_bytesize should be an integer or nil.
12054 # nil means unlimited.
12055 # If it is omitted, nil is assumed.
12056 # 
12057 # opt should be nil, a hash or an integer.
12058 # nil means no flags.
12059 # If it is omitted, nil is assumed.
12060 # 
12061 # primitive_convert converts the content of source_buffer from beginning
12062 # and store the result into destination_buffer.
12063 # 
12064 # destination_byteoffset and destination_bytesize specify the region which
12065 # the converted result is stored.
12066 # destination_byteoffset specifies the start position in destination_buffer in bytes.
12067 # If destination_byteoffset is nil,
12068 # destination_buffer.bytesize is used for appending the result.
12069 # destination_bytesize specifies maximum number of bytes.
12070 # If destination_bytesize is nil,
12071 # destination size is unlimited.
12072 # After conversion, destination_buffer is resized to
12073 # destination_byteoffset + actually produced number of bytes.
12074 # Also destination_buffer's encoding is set to destination_encoding.
12075 # 
12076 # primitive_convert drops the converted part of source_buffer.
12077 # the dropped part is converted in destination_buffer or
12078 # buffered in Encoding::Converter object.
12079 # 
12080 # primitive_convert stops conversion when one of following condition met.
12081 # - invalid byte sequence found in source buffer (:invalid_byte_sequence)
12082 #   +primitive_errinfo+ and +last_error+ methods returns the detail of the error.
12083 # - unexpected end of source buffer (:incomplete_input)
12084 #   this occur only when :partial_input is not specified.
12085 #   +primitive_errinfo+ and +last_error+ methods returns the detail of the error.
12086 # - character not representable in output encoding (:undefined_conversion)
12087 #   +primitive_errinfo+ and +last_error+ methods returns the detail of the error.
12088 # - after some output is generated, before input is done (:after_output)
12089 #   this occur only when :after_output is specified.
12090 # - destination buffer is full (:destination_buffer_full)
12091 #   this occur only when destination_bytesize is non-nil.
12092 # - source buffer is empty (:source_buffer_empty)
12093 #   this occur only when :partial_input is specified.
12094 # - conversion is finished (:finished)
12095 # 
12096 # example:
12097 #   ec = Encoding::Converter.new("UTF-8", "UTF-16BE")
12098 #   ret = ec.primitive_convert(src="pi", dst="", nil, 100)
12099 #   p [ret, src, dst] #=> [:finished, "", "\x00p\x00i"]
12100 # 
12101 #   ec = Encoding::Converter.new("UTF-8", "UTF-16BE")
12102 #   ret = ec.primitive_convert(src="pi", dst="", nil, 1)
12103 #   p [ret, src, dst] #=> [:destination_buffer_full, "i", "\x00"]
12104 #   ret = ec.primitive_convert(src, dst="", nil, 1)
12105 #   p [ret, src, dst] #=> [:destination_buffer_full, "", "p"]
12106 #   ret = ec.primitive_convert(src, dst="", nil, 1)
12107 #   p [ret, src, dst] #=> [:destination_buffer_full, "", "\x00"]
12108 #   ret = ec.primitive_convert(src, dst="", nil, 1)
12109 #   p [ret, src, dst] #=> [:finished, "", "i"]
12110 def primitive_convert(source_buffer, destination_buffer); :a; end
12111 ##
12112 # Convert source_string and return destination_string.
12113 # 
12114 # source_string is assumed as a part of source.
12115 # i.e.  :partial_input=>true is specified internally.
12116 # finish method should be used last.
12117 # 
12118 #   ec = Encoding::Converter.new("utf-8", "euc-jp")
12119 #   puts ec.convert("\u3042").dump     #=> "\xA4\xA2"
12120 #   puts ec.finish.dump                #=> ""
12121 # 
12122 #   ec = Encoding::Converter.new("euc-jp", "utf-8")
12123 #   puts ec.convert("\xA4").dump       #=> ""
12124 #   puts ec.convert("\xA2").dump       #=> "\xE3\x81\x82"
12125 #   puts ec.finish.dump                #=> ""
12126 # 
12127 #   ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
12128 #   puts ec.convert("\xE3").dump       #=> "".force_encoding("ISO-2022-JP")
12129 #   puts ec.convert("\x81").dump       #=> "".force_encoding("ISO-2022-JP")
12130 #   puts ec.convert("\x82").dump       #=> "\e$B$\"".force_encoding("ISO-2022-JP")
12131 #   puts ec.finish.dump                #=> "\e(B".force_encoding("ISO-2022-JP")
12132 # 
12133 # If a conversion error occur,
12134 # Encoding::UndefinedConversionError or
12135 # Encoding::InvalidByteSequenceError is raised.
12136 # Encoding::Converter#convert doesn't supply methods to recover or restart
12137 # from these exceptions.
12138 # When you want to handle these conversion errors,
12139 # use Encoding::Converter#primitive_convert.
12140 def convert(source_string); ''; end
12141 ##
12142 # Finishes the converter.
12143 # It returns the last part of the converted string.
12144 # 
12145 #   ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
12146 #   p ec.convert("\u3042")     #=> "\e$B$\""
12147 #   p ec.finish                #=> "\e(B"
12148 def finish; ''; end
12149 ##
12150 # primitive_errinfo returns important information regarding the last error
12151 # as a 5-element array:
12152 # 
12153 #   [result, enc1, enc2, error_bytes, readagain_bytes]
12154 # 
12155 # result is the last result of primitive_convert.
12156 # 
12157 # Other elements are only meaningful when result is
12158 # :invalid_byte_sequence, :incomplete_input or :undefined_conversion.
12159 # 
12160 # enc1 and enc2 indicate a conversion step as a pair of strings.
12161 # For example, a converter from EUC-JP to ISO-8859-1 converts
12162 # a string as follows: EUC-JP -> UTF-8 -> ISO-8859-1.
12163 # So [enc1, enc2] is either ["EUC-JP", "UTF-8"] or ["UTF-8", "ISO-8859-1"].
12164 # 
12165 # error_bytes and readagain_bytes indicate the byte sequences which caused the error.
12166 # error_bytes is discarded portion.
12167 # readagain_bytes is buffered portion which is read again on next conversion.
12168 # 
12169 # Example:
12170 # 
12171 #   # \xff is invalid as EUC-JP.
12172 #   ec = Encoding::Converter.new("EUC-JP", "Shift_JIS")
12173 #   ec.primitive_convert(src="\xff", dst="", nil, 10)
12174 #   p ec.primitive_errinfo
12175 #   #=> [:invalid_byte_sequence, "EUC-JP", "UTF-8", "\xFF", ""]
12176 # 
12177 #   # HIRAGANA LETTER A (\xa4\xa2 in EUC-JP) is not representable in ISO-8859-1.
12178 #   # Since this error is occur in UTF-8 to ISO-8859-1 conversion,
12179 #   # error_bytes is HIRAGANA LETTER A in UTF-8 (\xE3\x81\x82).
12180 #   ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
12181 #   ec.primitive_convert(src="\xa4\xa2", dst="", nil, 10)
12182 #   p ec.primitive_errinfo
12183 #   #=> [:undefined_conversion, "UTF-8", "ISO-8859-1", "\xE3\x81\x82", ""]
12184 # 
12185 #   # partial character is invalid
12186 #   ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
12187 #   ec.primitive_convert(src="\xa4", dst="", nil, 10)
12188 #   p ec.primitive_errinfo
12189 #   #=> [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""]
12190 # 
12191 #   # Encoding::Converter::PARTIAL_INPUT prevents invalid errors by
12192 #   # partial characters.
12193 #   ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
12194 #   ec.primitive_convert(src="\xa4", dst="", nil, 10, Encoding::Converter::PARTIAL_INPUT)
12195 #   p ec.primitive_errinfo
12196 #   #=> [:source_buffer_empty, nil, nil, nil, nil]
12197 # 
12198 #   # \xd8\x00\x00@ is invalid as UTF-16BE because
12199 #   # no low surrogate after high surrogate (\xd8\x00).
12200 #   # It is detected by 3rd byte (\00) which is part of next character.
12201 #   # So the high surrogate (\xd8\x00) is discarded and
12202 #   # the 3rd byte is read again later.
12203 #   # Since the byte is buffered in ec, it is dropped from src.
12204 #   ec = Encoding::Converter.new("UTF-16BE", "UTF-8")
12205 #   ec.primitive_convert(src="\xd8\x00\x00@", dst="", nil, 10)
12206 #   p ec.primitive_errinfo
12207 #   #=> [:invalid_byte_sequence, "UTF-16BE", "UTF-8", "\xD8\x00", "\x00"]
12208 #   p src
12209 #   #=> "@"
12210 # 
12211 #   # Similar to UTF-16BE, \x00\xd8@\x00 is invalid as UTF-16LE.
12212 #   # The problem is detected by 4th byte.
12213 #   ec = Encoding::Converter.new("UTF-16LE", "UTF-8")
12214 #   ec.primitive_convert(src="\x00\xd8@\x00", dst="", nil, 10)
12215 #   p ec.primitive_errinfo
12216 #   #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "@\x00"]
12217 #   p src
12218 #   #=> ""
12219 def primitive_errinfo; []; end
12220 ##
12221 # Inserts string into the encoding converter.
12222 # The string will be converted to the destination encoding and
12223 # output on later conversions.
12224 # 
12225 # If the destination encoding is stateful,
12226 # string is converted according to the state and the state is updated.
12227 # 
12228 # This method should be used only when a conversion error occurs.
12229 # 
12230 #  ec = Encoding::Converter.new("utf-8", "iso-8859-1")
12231 #  src = "HIRAGANA LETTER A is \u{3042}."
12232 #  dst = ""
12233 #  p ec.primitive_convert(src, dst)    #=> :undefined_conversion
12234 #  puts "[#{dst.dump}, #{src.dump}]"   #=> ["HIRAGANA LETTER A is ", "."]
12235 #  ec.insert_output("<err>")
12236 #  p ec.primitive_convert(src, dst)    #=> :finished
12237 #  puts "[#{dst.dump}, #{src.dump}]"   #=> ["HIRAGANA LETTER A is <err>.", ""]
12238 # 
12239 #  ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
12240 #  src = "\u{306F 3041 3068 2661 3002}" # U+2661 is not representable in iso-2022-jp
12241 #  dst = ""
12242 #  p ec.primitive_convert(src, dst)    #=> :undefined_conversion
12243 #  puts "[#{dst.dump}, #{src.dump}]"   #=> ["\e$B$O$!$H".force_encoding("ISO-2022-JP"), "\xE3\x80\x82"]
12244 #  ec.insert_output "?"                # state change required to output "?".
12245 #  p ec.primitive_convert(src, dst)    #=> :finished
12246 #  puts "[#{dst.dump}, #{src.dump}]"   #=> ["\e$B$O$!$H\e(B?\e$B!#\e(B".force_encoding("ISO-2022-JP"), ""]
12247 def insert_output(string); end
12248 ##
12249 # Returns an exception object for the last conversion.
12250 # Returns nil if the last conversion did not produce an error.
12251 # 
12252 # "error" means that
12253 # Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for
12254 # Encoding::Converter#convert and
12255 # :invalid_byte_sequence, :incomplete_input and :undefined_conversion for
12256 # Encoding::Converter#primitive_convert.
12257 # 
12258 #  ec = Encoding::Converter.new("utf-8", "iso-8859-1")
12259 #  p ec.primitive_convert(src="\xf1abcd", dst="")       #=> :invalid_byte_sequence
12260 #  p ec.last_error      #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
12261 #  p ec.primitive_convert(src, dst, nil, 1)             #=> :destination_buffer_full
12262 #  p ec.last_error      #=> nil
12263 def last_error; Exception.new || nil; end
12264 ##
12265 # Returns the replacement string.
12266 # 
12267 #  ec = Encoding::Converter.new("euc-jp", "us-ascii")
12268 #  p ec.replacement    #=> "?"
12269 # 
12270 #  ec = Encoding::Converter.new("euc-jp", "utf-8")
12271 #  p ec.replacement    #=> "\uFFFD"
12272 def replacement; ''; end
12273 ##
12274 # Sets the replacement string.
12275 # 
12276 #  ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
12277 #  ec.replacement = "<undef>"
12278 #  p ec.convert("a \u3042 b")      #=> "a <undef> b"
12279 def replacement= string; end
12280 def ==; true || false; end
12281 end
12282 
12283 ##
12284 # Returns the name of the encoding.
12285 # 
12286 #   Encoding::UTF_8.name      #=> "UTF-8"
12287 def name; ''; end
12288 ##
12289 # Returns a string which represents the encoding for programmers.
12290 # 
12291 #   Encoding::UTF_8.inspect       #=> "#<Encoding:UTF-8>"
12292 #   Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
12293 def inspect; ''; end
12294 ##
12295 # Returns the list of name and aliases of the encoding.
12296 # 
12297 #   Encoding::WINDOWS_31J.names  #=> ["Windows-31J", "CP932", "csWindows31J"]
12298 def names; []; end
12299 ##
12300 # Returns true for dummy encodings.
12301 # A dummy encoding is an encoding for which character handling is not properly
12302 # implemented.
12303 # It is used for stateful encodings.
12304 # 
12305 #   Encoding::ISO_2022_JP.dummy?       #=> true
12306 #   Encoding::UTF_8.dummy?             #=> false
12307 def dummy?; true || false; end
12308 ##
12309 # Returns whether ASCII-compatible or not.
12310 # 
12311 #   Encoding::UTF_8.ascii_compatible?     #=> true
12312 #   Encoding::UTF_16BE.ascii_compatible?  #=> false
12313 def ascii_compatible?; true || false; end
12314 ##
12315 # Returns a replicated encoding of _enc_ whose name is _name_.
12316 # The new encoding should have the same byte structure of _enc_.
12317 # If _name_ is used by another encoding, raise ArgumentError.
12318 def replicate(name); Encoding.new; end
12319 ##
12320 # Returns the list of loaded encodings.
12321 # 
12322 #   Encoding.list
12323 #   #=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
12324 #         #<Encoding:ISO-2022-JP (dummy)>]
12325 # 
12326 #   Encoding.find("US-ASCII")
12327 #   #=> #<Encoding:US-ASCII>
12328 # 
12329 #   Encoding.list
12330 #   #=> [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>,
12331 #         #<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
12332 def self.list; [Encoding.new]; end
12333 ##
12334 # Returns the list of available encoding names.
12335 # 
12336 #   Encoding.name_list
12337 #   #=> ["US-ASCII", "ASCII-8BIT", "UTF-8",
12338 #         "ISO-8859-1", "Shift_JIS", "EUC-JP",
12339 #         "Windows-31J",
12340 #         "BINARY", "CP932", "eucJP"]
12341 def self.name_list; [Encoding.new]; end
12342 ##
12343 # Returns the hash of available encoding alias and original encoding name.
12344 # 
12345 #   Encoding.aliases
12346 #   #=> {"BINARY"=>"ASCII-8BIT", "ASCII"=>"US-ASCII", "ANSI_X3.4-1986"=>"US-ASCII",
12347 #         "SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
12348 def self.aliases(&block); end
12349 ##
12350 # Search the encoding with specified <i>name</i>.
12351 # <i>name</i> should be a string or symbol.
12352 # 
12353 #   Encoding.find("US-ASCII")  #=> #<Encoding:US-ASCII>
12354 #   Encoding.find(:Shift_JIS)  #=> #<Encoding:Shift_JIS>
12355 # 
12356 # Names which this method accept are encoding names and aliases
12357 # including following special aliases
12358 # 
12359 # "external"::   default external encoding
12360 # "internal"::   default internal encoding
12361 # "locale"::     locale encoding
12362 # "filesystem":: filesystem encoding
12363 # 
12364 # An ArgumentError is raised when no encoding with <i>name</i>.
12365 # Only <code>Encoding.find("internal")</code> however returns nil
12366 # when no encoding named "internal", in other words, when Ruby has no
12367 # default internal encoding.
12368 def self.find(string); Encoding.new; end
12369 ##
12370 # Checks the compatibility of two objects.
12371 # 
12372 # If the objects are both strings they are compatible when they are
12373 # concatenatable.  The encoding of the concatenated string will be returned
12374 # if they are compatible, nil if they are not.
12375 # 
12376 #   Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b")
12377 #   #=> #<Encoding:ISO-8859-1>
12378 # 
12379 #   Encoding.compatible?(
12380 #     "\xa1".force_encoding("iso-8859-1"),
12381 #     "\xa1\xa1".force_encoding("euc-jp"))
12382 #   #=> nil
12383 # 
12384 # If the objects are non-strings their encodings are compatible when they
12385 # have an encoding and:
12386 # * Either encoding is US-ASCII compatible
12387 # * One of the encodings is a 7-bit encoding
12388 def self.compatible?(obj1, obj2); Encoding.new || nil; end
12389 ##
12390 # Returns default external encoding.
12391 # 
12392 # The default external encoding is used by default for strings created from
12393 # the following locations:
12394 # 
12395 # * CSV
12396 # * File data read from disk
12397 # * SDBM
12398 # * StringIO
12399 # * Zlib::GzipReader
12400 # * Zlib::GzipWriter
12401 # * String#inspect
12402 # * Regexp#inspect
12403 # 
12404 # While strings created from these locations will have this encoding, the
12405 # encoding may not be valid.  Be sure to check String#valid_encoding?.
12406 # 
12407 # File data written to disk will be transcoded to the default external
12408 # encoding when written.
12409 # 
12410 # The default external encoding is initialized by the locale or -E option.
12411 def self.default_external; Encoding.new; end
12412 ##
12413 # Sets default external encoding.  You should not set
12414 # Encoding::default_external in ruby code as strings created before changing
12415 # the value may have a different encoding from strings created after the value
12416 # was changed., instead you should use <tt>ruby -E</tt> to invoke ruby with
12417 # the correct default_external.
12418 # 
12419 # See Encoding::default_external for information on how the default external
12420 # encoding is used.
12421 def self.default_external= enc; end
12422 ##
12423 # Returns default internal encoding.  Strings will be transcoded to the
12424 # default internal encoding in the following places if the default internal
12425 # encoding is not nil:
12426 # 
12427 # * CSV
12428 # * Etc.sysconfdir and Etc.systmpdir
12429 # * File data read from disk
12430 # * File names from Dir
12431 # * Integer#chr
12432 # * String#inspect and Regexp#inspect
12433 # * Strings returned from Curses
12434 # * Strings returned from Readline
12435 # * Strings returned from SDBM
12436 # * Time#zone
12437 # * Values from ENV
12438 # * Values in ARGV including $PROGRAM_NAME
12439 # * __FILE__
12440 # 
12441 # Additionally String#encode and String#encode! use the default internal
12442 # encoding if no encoding is given.
12443 # 
12444 # The locale encoding (__ENCODING__), not default_internal, is used as the
12445 # encoding of created strings.
12446 # 
12447 # Encoding::default_internal is initialized by the source file's
12448 # internal_encoding or -E option.
12449 def self.default_internal; Encoding.new; end
12450 ##
12451 # Sets default internal encoding or removes default internal encoding when
12452 # passed nil.  You should not set Encoding::default_internal in ruby code as
12453 # strings created before changing the value may have a different encoding
12454 # from strings created after the change.  Instead you should use
12455 # <tt>ruby -E</tt> to invoke ruby with the correct default_internal.
12456 # 
12457 # See Encoding::default_internal for information on how the default internal
12458 # encoding is used.
12459 def self.default_internal= enc_or_nil; end
12460 ##
12461 # Returns the locale charmap name.
12462 # It returns nil if no appropriate information.
12463 # 
12464 #   Debian GNU/Linux
12465 #     LANG=C
12466 #       Encoding.locale_charmap  #=> "ANSI_X3.4-1968"
12467 #     LANG=ja_JP.EUC-JP
12468 #       Encoding.locale_charmap  #=> "EUC-JP"
12469 # 
12470 #   SunOS 5
12471 #     LANG=C
12472 #       Encoding.locale_charmap  #=> "646"
12473 #     LANG=ja
12474 #       Encoding.locale_charmap  #=> "eucJP"
12475 # 
12476 # The result is highly platform dependent.
12477 # So Encoding.find(Encoding.locale_charmap) may cause an error.
12478 # If you need some encoding object even for unknown locale,
12479 # Encoding.find("locale") can be used.
12480 def self.locale_charmap; ''; end
12481 end
12482 
12483 class Class < Module
12484 ##
12485 # Callback invoked whenever a subclass of the current class is created.
12486 # 
12487 # Example:
12488 # 
12489 #    class Foo
12490 #      def self.inherited(subclass)
12491 #        puts "New subclass: #{subclass}"
12492 #      end
12493 #    end
12494 # 
12495 #    class Bar < Foo
12496 #    end
12497 # 
12498 #    class Baz < Bar
12499 #    end
12500 # 
12501 # produces:
12502 # 
12503 #    New subclass: Bar
12504 #    New subclass: Baz
12505 def inherited(subklass); end
12506 ##
12507 # Allocates space for a new object of <i>class</i>'s class and does not
12508 # call initialize on the new instance. The returned object must be an
12509 # instance of <i>class</i>.
12510 # 
12511 #     klass = Class.new do
12512 #       def initialize(*args)
12513 #         @initialized = true
12514 #       end
12515 # 
12516 #       def initialized?
12517 #         @initialized || false
12518 #       end
12519 #     end
12520 # 
12521 #     klass.allocate.initialized? #=> false
12522 def allocate(); Object.new; end
12523 ##
12524 # Calls <code>allocate</code> to create a new object of
12525 # <i>class</i>'s class, then invokes that object's
12526 # <code>initialize</code> method, passing it <i>args</i>.
12527 # This is the method that ends up getting called whenever
12528 # an object is constructed using .new.
12529 def new(super_klass=Object, &block); Class.new; end
12530 ##
12531 # Returns the superclass of <i>class</i>, or <code>nil</code>.
12532 # 
12533 #    File.superclass          #=> IO
12534 #    IO.superclass            #=> Object
12535 #    Object.superclass        #=> BasicObject
12536 #    class Foo; end
12537 #    class Bar < Foo; end
12538 #    Bar.superclass           #=> Foo
12539 # 
12540 # returns nil when the given class hasn't a parent class:
12541 # 
12542 #    BasicObject.superclass   #=> nil
12543 def superclass; Class.new || nil; end
12544 end
12545 
12546 ##
12547 # Descendants of class Exception are used to communicate between
12548 # Kernel#raise and +rescue+ statements in <code>begin ... end</code> blocks.
12549 # Exception objects carry information about the exception -- its type (the
12550 # exception's class name), an optional descriptive string, and optional
12551 # traceback information.  Exception subclasses may add additional
12552 # information like NameError#name.
12553 # 
12554 # Programs may make subclasses of Exception, typically of StandardError or
12555 # RuntimeError, to provide custom classes and add additional information.
12556 # See the subclass list below for defaults for +raise+ and +rescue+.
12557 # 
12558 # When an exception has been raised but not yet handled (in +rescue+,
12559 # +ensure+, +at_exit+ and +END+ blocks) the global variable <code>$!</code>
12560 # will contain the current exception and <code>$@</code> contains the
12561 # current exception's backtrace.
12562 # 
12563 # It is recommended that a library should have one subclass of StandardError
12564 # or RuntimeError and have specific exception types inherit from it.  This
12565 # allows the user to rescue a generic exception type to catch all exceptions
12566 # the library may raise even if future versions of the library add new
12567 # exception subclasses.
12568 # 
12569 # For example:
12570 # 
12571 #   class MyLibrary
12572 #     class Error < RuntimeError
12573 #     end
12574 # 
12575 #     class WidgetError < Error
12576 #     end
12577 # 
12578 #     class FrobError < Error
12579 #     end
12580 # 
12581 #   end
12582 # 
12583 # To handle both WidgetError and FrobError the library user can rescue
12584 # MyLibrary::Error.
12585 # 
12586 # The built-in subclasses of Exception are:
12587 # 
12588 # * NoMemoryError
12589 # * ScriptError
12590 #   * LoadError
12591 #   * NotImplementedError
12592 #   * SyntaxError
12593 # * SignalException
12594 #   * Interrupt
12595 # * StandardError -- default for +rescue+
12596 #   * ArgumentError
12597 #   * IndexError
12598 #     * StopIteration
12599 #   * IOError
12600 #     * EOFError
12601 #   * LocalJumpError
12602 #   * NameError
12603 #     * NoMethodError
12604 #   * RangeError
12605 #     * FloatDomainError
12606 #   * RegexpError
12607 #   * RuntimeError -- default for +raise+
12608 #   * SecurityError
12609 #   * SystemCallError
12610 #     * Errno::*
12611 #   * SystemStackError
12612 #   * ThreadError
12613 #   * TypeError
12614 #   * ZeroDivisionError
12615 # * SystemExit
12616 # * fatal -- impossible to rescue
12617 class Exception < Object
12618 ##
12619 # With no argument, or if the argument is the same as the receiver,
12620 # return the receiver. Otherwise, create a new
12621 # exception object of the same class as the receiver, but with a
12622 # message equal to <code>string.to_str</code>.
12623 def self.exception(string); Exception.new; end
12624 ##
12625 # Construct a new Exception object, optionally passing in
12626 # a message.
12627 def self.new(msg = null); end
12628 ##
12629 # Equality---If <i>obj</i> is not an <code>Exception</code>, returns
12630 # <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
12631 # <i>obj</i> share same class, messages, and backtrace.
12632 def ==; true || false; end
12633 ##
12634 # Returns exception's message (or the name of the exception if
12635 # no message is set).
12636 def to_s; ''; end
12637 ##
12638 # Returns the result of invoking <code>exception.to_s</code>.
12639 # Normally this returns the exception's message or name. By
12640 # supplying a to_str method, exceptions are agreeing to
12641 # be used where Strings are expected.
12642 def message; ''; end
12643 ##
12644 # Return this exception's class name and message
12645 def inspect; ''; end
12646 ##
12647 # Returns any backtrace associated with the exception. The backtrace
12648 # is an array of strings, each containing either ``filename:lineNo: in
12649 # `method''' or ``filename:lineNo.''
12650 # 
12651 #    def a
12652 #      raise "boom"
12653 #    end
12654 # 
12655 #    def b
12656 #      a()
12657 #    end
12658 # 
12659 #    begin
12660 #      b()
12661 #    rescue => detail
12662 #      print detail.backtrace.join("\n")
12663 #    end
12664 # 
12665 # <em>produces:</em>
12666 # 
12667 #    prog.rb:2:in `a'
12668 #    prog.rb:6:in `b'
12669 #    prog.rb:10
12670 def backtrace; []; end
12671 ##
12672 # Sets the backtrace information associated with +exc+. The +backtrace+ must
12673 # be an array of String objects or a single String in the format described
12674 # in Exception#backtrace.
12675 def set_backtrace(backtrace); []; end
12676 end
12677 
12678 ##
12679 # Raised by +exit+ to initiate the termination of the script.
12680 class SystemExit < Exception
12681 ##
12682 # Create a new +SystemExit+ exception with the given status and message.
12683 # Status is true, false, or an integer.
12684 # If status is not given, true is used.
12685 def self.new; end
12686 ##
12687 # Return the status value associated with this system exit.
12688 def status; 0; end
12689 ##
12690 # Returns +true+ if exiting successful, +false+ if not.
12691 def success?; true || false; end
12692 end
12693 
12694 ##
12695 # fatal is an Exception that is raised when ruby has encountered a fatal
12696 # error and must exit.  You are not able to rescue fatal.
12697 class Fatal < Exception
12698 end
12699 
12700 ##
12701 # Raised when a signal is received.
12702 # 
12703 #    begin
12704 #      Process.kill('HUP',Process.pid)
12705 #      sleep # wait for receiver to handle signal sent by Process.kill
12706 #    rescue SignalException => e
12707 #      puts "received Exception #{e}"
12708 #    end
12709 # 
12710 # <em>produces:</em>
12711 # 
12712 #    received Exception SIGHUP
12713 class SignalException < Exception
12714 ##
12715 # Construct a new SignalException object.  +sig_name+ should be a known
12716 # signal name.
12717 def self.new(sig_name); end
12718 ##
12719 # Returns a signal number.
12720 def signo; 0; end
12721 end
12722 
12723 ##
12724 # Raised with the interrupt signal is received, typically because the
12725 # user pressed on Control-C (on most posix platforms). As such, it is a
12726 # subclass of +SignalException+.
12727 # 
12728 #    begin
12729 #      puts "Press ctrl-C when you get bored"
12730 #      loop {}
12731 #    rescue Interrupt => e
12732 #      puts "Note: You will typically use Signal.trap instead."
12733 #    end
12734 # 
12735 # <em>produces:</em>
12736 # 
12737 #    Press ctrl-C when you get bored
12738 # 
12739 # <em>then waits until it is interrupted with Control-C and then prints:</em>
12740 # 
12741 #    Note: You will typically use Signal.trap instead.
12742 class Interrupt < SignalException
12743 end
12744 
12745 ##
12746 # The most standard error types are subclasses of StandardError. A
12747 # rescue clause without an explicit Exception class will rescue all
12748 # StandardErrors (and only those).
12749 # 
12750 #    def foo
12751 #      raise "Oups"
12752 #    end
12753 #    foo rescue "Hello"   #=> "Hello"
12754 # 
12755 # On the other hand:
12756 # 
12757 #    require 'does/not/exist' rescue "Hi"
12758 # 
12759 # <em>raises the exception:</em>
12760 # 
12761 #    LoadError: no such file to load -- does/not/exist
12762 class StandardError < Exception
12763 end
12764 
12765 ##
12766 # Raised when encountering an object that is not of the expected type.
12767 # 
12768 #    [1, 2, 3].first("two")
12769 # 
12770 # <em>raises the exception:</em>
12771 # 
12772 #    TypeError: no implicit conversion of String into Integer
12773 class TypeError < StandardError
12774 end
12775 
12776 ##
12777 # Raised when the arguments are wrong and there isn't a more specific
12778 # Exception class.
12779 # 
12780 # Ex: passing the wrong number of arguments
12781 # 
12782 #    [1, 2, 3].first(4, 5)
12783 # 
12784 # <em>raises the exception:</em>
12785 # 
12786 #    ArgumentError: wrong number of arguments (2 for 1)
12787 # 
12788 # Ex: passing an argument that is not acceptable:
12789 # 
12790 #    [1, 2, 3].first(-4)
12791 # 
12792 # <em>raises the exception:</em>
12793 # 
12794 #    ArgumentError: negative array size
12795 class ArgumentError < StandardError
12796 end
12797 
12798 ##
12799 # Raised when the given index is invalid.
12800 # 
12801 #    a = [:foo, :bar]
12802 #    a.fetch(0)   #=> :foo
12803 #    a[4]         #=> nil
12804 #    a.fetch(4)   #=> IndexError: index 4 outside of array bounds: -2...2
12805 class IndexError < StandardError
12806 end
12807 
12808 ##
12809 # Raised when the specified key is not found. It is a subclass of
12810 # IndexError.
12811 # 
12812 #    h = {"foo" => :bar}
12813 #    h.fetch("foo") #=> :bar
12814 #    h.fetch("baz") #=> KeyError: key not found: "baz"
12815 class KeyError < IndexError
12816 end
12817 
12818 ##
12819 # Raised when a given numerical value is out of range.
12820 # 
12821 #    [1, 2, 3].drop(1 << 100)
12822 # 
12823 # <em>raises the exception:</em>
12824 # 
12825 #    RangeError: bignum too big to convert into `long'
12826 class RangeError < StandardError
12827 end
12828 
12829 ##
12830 # ScriptError is the superclass for errors raised when a script
12831 # can not be executed because of a +LoadError+,
12832 # +NotImplementedError+ or a +SyntaxError+. Note these type of
12833 # +ScriptErrors+ are not +StandardError+ and will not be
12834 # rescued unless it is specified explicitly (or its ancestor
12835 # +Exception+).
12836 class ScriptError < Exception
12837 end
12838 
12839 ##
12840 # Raised when encountering Ruby code with an invalid syntax.
12841 # 
12842 #    eval("1+1=2")
12843 # 
12844 # <em>raises the exception:</em>
12845 # 
12846 #    SyntaxError: (eval):1: syntax error, unexpected '=', expecting $end
12847 class SyntaxError < ScriptError
12848 end
12849 
12850 ##
12851 # Raised when a file required (a Ruby script, extension library, ...)
12852 # fails to load.
12853 # 
12854 #    require 'this/file/does/not/exist'
12855 # 
12856 # <em>raises the exception:</em>
12857 # 
12858 #    LoadError: no such file to load -- this/file/does/not/exist
12859 class LoadError < ScriptError
12860 end
12861 
12862 ##
12863 # Raised when a feature is not implemented on the current platform. For
12864 # example, methods depending on the +fsync+ or +fork+ system calls may
12865 # raise this exception if the underlying operating system or Ruby
12866 # runtime does not support them.
12867 # 
12868 # Note that if +fork+ raises a +NotImplementedError+, then
12869 # <code>respond_to?(:fork)</code> returns +false+.
12870 class NotImplementedError < ScriptError
12871 end
12872 
12873 ##
12874 # Raised when a given name is invalid or undefined.
12875 # 
12876 #    puts foo
12877 # 
12878 # <em>raises the exception:</em>
12879 # 
12880 #    NameError: undefined local variable or method `foo' for main:Object
12881 # 
12882 # Since constant names must start with a capital:
12883 # 
12884 #    Fixnum.const_set :answer, 42
12885 # 
12886 # <em>raises the exception:</em>
12887 # 
12888 #    NameError: wrong constant name answer
12889 class NameError < StandardError
12890 class Message < Data
12891 end
12892 
12893 ##
12894 # Construct a new NameError exception. If given the <i>name</i>
12895 # parameter may subsequently be examined using the <code>NameError.name</code>
12896 # method.
12897 def self.new(msg , name=0); end
12898 ##
12899 # Return the name associated with this NameError exception.
12900 def name; '' || nil; end
12901 ##
12902 # Produce a nicely-formatted string representing the +NameError+.
12903 def to_s; ''; end
12904 end
12905 
12906 ##
12907 # Raised when a method is called on a receiver which doesn't have it
12908 # defined and also fails to respond with +method_missing+.
12909 # 
12910 #    "hello".to_ary
12911 # 
12912 # <em>raises the exception:</em>
12913 # 
12914 #    NoMethodError: undefined method `to_ary' for "hello":String
12915 class NoMethodError < NameError
12916 ##
12917 # Construct a NoMethodError exception for a method of the given name
12918 # called with the given arguments. The name may be accessed using
12919 # the <code>#name</code> method on the resulting object, and the
12920 # arguments using the <code>#args</code> method.
12921 def self.new(msg, name , args=0); end
12922 ##
12923 # Return the arguments passed in as the third parameter to
12924 # the constructor.
12925 def args; Object.new; end
12926 end
12927 
12928 ##
12929 # A generic error class raised when an invalid operation is attempted.
12930 # 
12931 #    [1, 2, 3].freeze << 4
12932 # 
12933 # <em>raises the exception:</em>
12934 # 
12935 #    RuntimeError: can't modify frozen array
12936 # 
12937 # Kernel.raise will raise a RuntimeError if no Exception class is
12938 # specified.
12939 # 
12940 #    raise "ouch"
12941 # 
12942 # <em>raises the exception:</em>
12943 # 
12944 #    RuntimeError: ouch
12945 class RuntimeError < StandardError
12946 end
12947 
12948 ##
12949 # Raised when attempting a potential unsafe operation, typically when
12950 # the $SAFE level is raised above 0.
12951 # 
12952 #    foo = "bar"
12953 #    proc = Proc.new do
12954 #      $SAFE = 4
12955 #      foo.gsub! "a", "*"
12956 #    end
12957 #    proc.call
12958 # 
12959 # <em>raises the exception:</em>
12960 # 
12961 #    SecurityError: Insecure: can't modify string
12962 class SecurityError < Exception
12963 end
12964 
12965 ##
12966 # Raised when memory allocation fails.
12967 class NoMemoryError < Exception
12968 end
12969 
12970 ##
12971 # EncodingError is the base class for encoding errors.
12972 class EncodingError < StandardError
12973 end
12974 
12975 ##
12976 # SystemCallError is the base class for all low-level
12977 # platform-dependent errors.
12978 # 
12979 # The errors available on the current platform are subclasses of
12980 # SystemCallError and are defined in the Errno module.
12981 # 
12982 #    File.open("does/not/exist")
12983 # 
12984 # <em>raises the exception:</em>
12985 # 
12986 #    Errno::ENOENT: No such file or directory - does/not/exist
12987 class SystemCallError < StandardError
12988 ##
12989 # If _errno_ corresponds to a known system error code, constructs
12990 # the appropriate <code>Errno</code> class for that error, otherwise
12991 # constructs a generic <code>SystemCallError</code> object. The
12992 # error number is subsequently available via the <code>errno</code>
12993 # method.
12994 def self.new(msg, errno); end
12995 ##
12996 # Return this SystemCallError's error number.
12997 def errno; 0; end
12998 ##
12999 # Return +true+ if the receiver is a generic +SystemCallError+, or
13000 # if the error numbers +self+ and _other_ are the same.
13001 def self.===; true || false; end
13002 end
13003 
13004 class Range < Object
13005 include Enumerable
13006 ##
13007 # Constructs a range using the given +begin+ and +end+. If the +exclude_end+
13008 # parameter is omitted or is <code>false</code>, the +rng+ will include
13009 # the end object; otherwise, it will be excluded.
13010 def self.new(_begin, _end, exclude__end=false); end
13011 ##
13012 # Returns <code>true</code> only if +obj+ is a Range, has equivalent
13013 # begin and end items (by comparing them with <code>==</code>), and has
13014 # the same #exclude_end? setting as the range.
13015 # 
13016 #   (0..2) == (0..2)            #=> true
13017 #   (0..2) == Range.new(0,2)    #=> true
13018 #   (0..2) == (0...2)           #=> false
13019 def ==; true || false; end
13020 ##
13021 # Returns <code>true</code> if +obj+ is an element of the range,
13022 # <code>false</code> otherwise.  Conveniently, <code>===</code> is the
13023 # comparison operator used by <code>case</code> statements.
13024 # 
13025 #    case 79
13026 #    when 1..50   then   print "low\n"
13027 #    when 51..75  then   print "medium\n"
13028 #    when 76..100 then   print "high\n"
13029 #    end
13030 # 
13031 # <em>produces:</em>
13032 # 
13033 #    high
13034 def ===; true || false; end
13035 ##
13036 # Returns <code>true</code> only if +obj+ is a Range, has equivalent
13037 # begin and end items (by comparing them with <code>eql?</code>),
13038 # and has the same #exclude_end? setting as the range.
13039 # 
13040 #   (0..2).eql?(0..2)            #=> true
13041 #   (0..2).eql?(Range.new(0,2))  #=> true
13042 #   (0..2).eql?(0...2)           #=> false
13043 def eql?(obj); true || false; end
13044 ##
13045 # Compute a hash-code for this range. Two ranges with equal
13046 # begin and end points (using <code>eql?</code>), and the same
13047 # #exclude_end? value will generate the same hash-code.
13048 def hash; 0; end
13049 ##
13050 # Iterates over the elements of range, passing each in turn to the
13051 # block.
13052 # 
13053 # The +each+ method can only be used if the begin object of the range
13054 # supports the +succ+ method.  A TypeError is raised if the object
13055 # does not have +succ+ method defined (like Float).
13056 # 
13057 # If no block is given, an enumerator is returned instead.
13058 # 
13059 #    (10..15).each {|n| print n, ' ' }
13060 #    # prints: 10 11 12 13 14 15
13061 # 
13062 #    (2.5..5).each {|n| print n, ' ' }
13063 #    # raises: TypeError: can't iterate from Float
13064 def each(&block); Enumerator.new; end
13065 ##
13066 # Iterates over the range, passing each <code>n</code>th element to the block.
13067 # If begin and end are numeric, +n+ is added for each iteration.
13068 # Otherwise <code>step</code> invokes <code>succ</code> to iterate through
13069 # range elements.
13070 # 
13071 # If no block is given, an enumerator is returned instead.
13072 # 
13073 #   range = Xs.new(1)..Xs.new(10)
13074 #   range.step(2) {|x| puts x}
13075 #   puts
13076 #   range.step(3) {|x| puts x}
13077 # 
13078 # <em>produces:</em>
13079 # 
13080 #    1 x
13081 #    3 xxx
13082 #    5 xxxxx
13083 #    7 xxxxxxx
13084 #    9 xxxxxxxxx
13085 # 
13086 #    1 x
13087 #    4 xxxx
13088 #    7 xxxxxxx
13089 #   10 xxxxxxxxxx
13090 # 
13091 # See Range for the definition of class Xs.
13092 def step(n=1, &block); Enumerator.new; end
13093 ##
13094 # By using binary search, finds a value in range which meets the given
13095 # condition in O(log n) where n is the size of the array.
13096 # 
13097 # You can use this method in two use cases: a find-minimum mode and
13098 # a find-any mode.  In either case, the elements of the array must be
13099 # monotone (or sorted) with respect to the block.
13100 # 
13101 # In find-minimum mode (this is a good choice for typical use case),
13102 # the block must return true or false, and there must be a value x
13103 # so that:
13104 # 
13105 # - the block returns false for any value which is less than x, and
13106 # - the block returns true for any value which is greater than or
13107 #   equal to i.
13108 # 
13109 # If x is within the range, this method returns the value x.
13110 # Otherwise, it returns nil.
13111 # 
13112 #    ary = [0, 4, 7, 10, 12]
13113 #    (0...ary.size).bsearch {|i| ary[i] >= 4 } #=> 1
13114 #    (0...ary.size).bsearch {|i| ary[i] >= 6 } #=> 2
13115 #    (0...ary.size).bsearch {|i| ary[i] >= 8 } #=> 3
13116 #    (0...ary.size).bsearch {|i| ary[i] >= 100 } #=> nil
13117 # 
13118 #    (0.0...Float::INFINITY).bsearch {|x| Math.log(x) >= 0 } #=> 1.0
13119 # 
13120 # In find-any mode (this behaves like libc's bsearch(3)), the block
13121 # must return a number, and there must be two values x and y (x <= y)
13122 # so that:
13123 # 
13124 # - the block returns a positive number for v if v < x,
13125 # - the block returns zero for v if x <= v < y, and
13126 # - the block returns a negative number for v if y <= v.
13127 # 
13128 # This method returns any value which is within the intersection of
13129 # the given range and x...y (if any).  If there is no value that
13130 # satisfies the condition, it returns nil.
13131 # 
13132 #    ary = [0, 100, 100, 100, 200]
13133 #    (0..4).bsearch {|i| 100 - ary[i] } #=> 1, 2 or 3
13134 #    (0..4).bsearch {|i| 300 - ary[i] } #=> nil
13135 #    (0..4).bsearch {|i|  50 - ary[i] } #=> nil
13136 # 
13137 # You must not mix the two modes at a time; the block must always
13138 # return either true/false, or always return a number.  It is
13139 # undefined which value is actually picked up at each iteration.
13140 def bsearch(&block); Object.new; end
13141 ##
13142 # Returns the object that defines the beginning of the range.
13143 # 
13144 #     (1..10).begin   #=> 1
13145 def begin; Object.new; end
13146 ##
13147 # Returns the object that defines the end of the range.
13148 # 
13149 #    (1..10).end    #=> 10
13150 #    (1...10).end   #=> 10
13151 def end; Object.new; end
13152 ##
13153 # Returns the first object in the range, or an array of the first +n+
13154 # elements.
13155 # 
13156 #   (10..20).first     #=> 10
13157 #   (10..20).first(3)  #=> [10, 11, 12]
13158 def first; []; end
13159 ##
13160 # Returns the last object in the range,
13161 # or an array of the last +n+ elements.
13162 # 
13163 # Note that with no arguments +last+ will return the object that defines
13164 # the end of the range even if #exclude_end? is +true+.
13165 # 
13166 #   (10..20).last      #=> 20
13167 #   (10...20).last     #=> 20
13168 #   (10..20).last(3)   #=> [18, 19, 20]
13169 #   (10...20).last(3)  #=> [17, 18, 19]
13170 def last; []; end
13171 ##
13172 # Returns the minimum value in the range. Returns +nil+ if the begin
13173 # value of the range is larger than the end value.
13174 # 
13175 # Can be given an optional block to override the default comparison
13176 # method <code>a <=> b</code>.
13177 # 
13178 #   (10..20).min    #=> 10
13179 def min; Object.new; end
13180 ##
13181 # Returns the maximum value in the range. Returns +nil+ if the begin
13182 # value of the range larger than the end value.
13183 # 
13184 # Can be given an optional block to override the default comparison
13185 # method <code>a <=> b</code>.
13186 # 
13187 #   (10..20).max    #=> 20
13188 def max; Object.new; end
13189 ##
13190 # Returns the number of elements in the range.
13191 # 
13192 #   (10..20).size    #=> 11
13193 def size; 0; end
13194 ##
13195 # Convert this range object to a printable form (using #to_s to convert the
13196 # begin and end objects).
13197 def to_s; ''; end
13198 ##
13199 # Convert this range object to a printable form (using
13200 # <code>inspect</code> to convert the begin and end
13201 # objects).
13202 def inspect; ''; end
13203 ##
13204 # Returns <code>true</code> if the range excludes its end value.
13205 # 
13206 #    (1..5).exclude_end?     #=> false
13207 #    (1...5).exclude_end?    #=> true
13208 def exclude_end?; true || false; end
13209 ##
13210 # Returns <code>true</code> if +obj+ is an element of
13211 # the range, <code>false</code> otherwise.  If begin and end are
13212 # numeric, comparison is done according to the magnitude of the values.
13213 # 
13214 #    ("a".."z").include?("g")   #=> true
13215 #    ("a".."z").include?("A")   #=> false
13216 #    ("a".."z").include?("cc")  #=> false
13217 def member?(obj); true || false; end
13218 ##
13219 # Returns <code>true</code> if +obj+ is an element of
13220 # the range, <code>false</code> otherwise.  If begin and end are
13221 # numeric, comparison is done according to the magnitude of the values.
13222 # 
13223 #    ("a".."z").include?("g")   #=> true
13224 #    ("a".."z").include?("A")   #=> false
13225 #    ("a".."z").include?("cc")  #=> false
13226 def include?(obj); true || false; end
13227 ##
13228 # Returns <code>true</code> if +obj+ is between the begin and end of
13229 # the range.
13230 # 
13231 # This tests <code>begin <= obj <= end</code> when #exclude_end? is +false+
13232 # and <code>begin <= obj < end</code> when #exclude_end? is +true+.
13233 # 
13234 #    ("a".."z").cover?("c")    #=> true
13235 #    ("a".."z").cover?("5")    #=> false
13236 #    ("a".."z").cover?("cc")   #=> true
13237 def cover?(obj); true || false; end
13238 end
13239 
13240 ##
13241 # Raised when attempting to divide an integer by 0.
13242 # 
13243 #    42 / 0
13244 # 
13245 # <em>raises the exception:</em>
13246 # 
13247 #    ZeroDivisionError: divided by 0
13248 # 
13249 # Note that only division by an exact 0 will raise that exception:
13250 # 
13251 #    42 /  0.0 #=> Float::INFINITY
13252 #    42 / -0.0 #=> -Float::INFINITY
13253 #    0  /  0.0 #=> NaN
13254 class ZeroDivisionError < StandardError
13255 end
13256 
13257 ##
13258 # Raised when attempting to convert special float values
13259 # (in particular infinite or NaN)
13260 # to numerical classes which don't support them.
13261 # 
13262 #    Float::INFINITY.to_r
13263 # 
13264 # <em>raises the exception:</em>
13265 # 
13266 #    FloatDomainError: Infinity
13267 class FloatDomainError < RangeError
13268 end
13269 
13270 ##
13271 # A <code>Fixnum</code> holds <code>Integer</code> values that can be
13272 # represented in a native machine word (minus 1 bit). If any operation
13273 # on a <code>Fixnum</code> exceeds this range, the value is
13274 # automatically converted to a <code>Bignum</code>.
13275 # 
13276 # <code>Fixnum</code> objects have immediate value. This means that
13277 # when they are assigned or passed as parameters, the actual object is
13278 # passed, rather than a reference to that object. Assignment does not
13279 # alias <code>Fixnum</code> objects. There is effectively only one
13280 # <code>Fixnum</code> object instance for any given integer value, so,
13281 # for example, you cannot add a singleton method to a
13282 # <code>Fixnum</code>.
13283 class Fixnum < Integer
13284 ##
13285 # Returns a string containing the representation of <i>fix</i> radix
13286 # <i>base</i> (between 2 and 36).
13287 # 
13288 #    12345.to_s       #=> "12345"
13289 #    12345.to_s(2)    #=> "11000000111001"
13290 #    12345.to_s(8)    #=> "30071"
13291 #    12345.to_s(10)   #=> "12345"
13292 #    12345.to_s(16)   #=> "3039"
13293 #    12345.to_s(36)   #=> "9ix"
13294 def to_s(base=10); ''; end
13295 ##
13296 # Negates <code>fix</code> (which might return a Bignum).
13297 def -@; 0; end
13298 ##
13299 # Performs addition: the class of the resulting object depends on
13300 # the class of <code>numeric</code> and on the magnitude of the
13301 # result.
13302 def +; 0; end
13303 ##
13304 # Performs subtraction: the class of the resulting object depends on
13305 # the class of <code>numeric</code> and on the magnitude of the
13306 # result.
13307 def -; 0; end
13308 ##
13309 # Performs multiplication: the class of the resulting object depends on
13310 # the class of <code>numeric</code> and on the magnitude of the
13311 # result.
13312 def *; 0; end
13313 ##
13314 # Performs division: the class of the resulting object depends on
13315 # the class of <code>numeric</code> and on the magnitude of the
13316 # result.
13317 def /; 0; end
13318 ##
13319 # Performs integer division: returns integer value.
13320 def div(numeric); 0; end
13321 ##
13322 # Returns <code>fix</code> modulo <code>other</code>.
13323 # See <code>numeric.divmod</code> for more information.
13324 def %; 0; end
13325 ##
13326 # Returns <code>fix</code> modulo <code>other</code>.
13327 # See <code>numeric.divmod</code> for more information.
13328 def modulo(other); 0; end
13329 ##
13330 # See <code>Numeric#divmod</code>.
13331 def divmod(numeric); []; end
13332 ##
13333 # Returns the floating point result of dividing <i>fix</i> by
13334 # <i>numeric</i>.
13335 # 
13336 #    654321.fdiv(13731)      #=> 47.6528293642124
13337 #    654321.fdiv(13731.24)   #=> 47.6519964693647
13338 def fdiv(numeric); 0.0; end
13339 ##
13340 # Raises <code>fix</code> to the <code>numeric</code> power, which may
13341 # be negative or fractional.
13342 # 
13343 #   2 ** 3      #=> 8
13344 #   2 ** -1     #=> (1/2)
13345 #   2 ** 0.5    #=> 1.4142135623731
13346 def **; 0; end
13347 ##
13348 # Returns the absolute value of <i>fix</i>.
13349 # 
13350 #    -12345.abs   #=> 12345
13351 #    12345.abs    #=> 12345
13352 def abs; 0; end
13353 ##
13354 # Returns the absolute value of <i>fix</i>.
13355 # 
13356 #    -12345.abs   #=> 12345
13357 #    12345.abs    #=> 12345
13358 def magnitude; 0; end
13359 ##
13360 # Return <code>true</code> if <code>fix</code> equals <code>other</code>
13361 # numerically.
13362 # 
13363 #   1 == 2      #=> false
13364 #   1 == 1.0    #=> true
13365 def ==; true || false; end
13366 ##
13367 # Return <code>true</code> if <code>fix</code> equals <code>other</code>
13368 # numerically.
13369 # 
13370 #   1 == 2      #=> false
13371 #   1 == 1.0    #=> true
13372 def ===; true || false; end
13373 ##
13374 # Comparison---Returns -1, 0, +1 or nil depending on whether +fix+ is less
13375 # than, equal to, or greater than +numeric+. This is the basis for the tests
13376 # in  Comparable.
13377 # 
13378 # +nil+ is returned if the two values are incomparable.
13379 def <=>; 1 || nil; end
13380 ##
13381 # Returns <code>true</code> if the value of <code>fix</code> is
13382 # greater than that of <code>real</code>.
13383 def >; true || false; end
13384 ##
13385 # Returns <code>true</code> if the value of <code>fix</code> is
13386 # greater than or equal to that of <code>real</code>.
13387 def >=; true || false; end
13388 ##
13389 # Returns <code>true</code> if the value of <code>fix</code> is
13390 # less than that of <code>real</code>.
13391 def <; true || false; end
13392 ##
13393 # Returns <code>true</code> if the value of <code>fix</code> is
13394 # less than or equal to that of <code>real</code>.
13395 def <=; true || false; end
13396 ##
13397 # One's complement: returns a number where each bit is flipped.
13398 def ~; 0; end
13399 ##
13400 # Bitwise AND.
13401 def &; 0; end
13402 ##
13403 # Bitwise OR.
13404 def |; 0; end
13405 ##
13406 # Bitwise EXCLUSIVE OR.
13407 def ^; 0; end
13408 ##
13409 # Bit Reference---Returns the <em>n</em>th bit in the binary
13410 # representation of <i>fix</i>, where <i>fix</i>[0] is the least
13411 # significant bit.
13412 # 
13413 #    a = 0b11001100101010
13414 #    30.downto(0) do |n| print a[n] end
13415 # 
13416 # <em>produces:</em>
13417 # 
13418 #    0000000000000000011001100101010
13419 def []; 0; end
13420 ##
13421 # Shifts _fix_ left _count_ positions (right if _count_ is negative).
13422 def <<; 0; end
13423 ##
13424 # Shifts _fix_ right _count_ positions (left if _count_ is negative).
13425 def >>; 0; end
13426 ##
13427 # Converts <i>fix</i> to a <code>Float</code>.
13428 def to_f; 0.0; end
13429 ##
13430 # Returns the number of <em>bytes</em> in the machine representation
13431 # of a <code>Fixnum</code>.
13432 # 
13433 #    1.size            #=> 4
13434 #    -1.size           #=> 4
13435 #    2147483647.size   #=> 4
13436 def size; 0; end
13437 ##
13438 # Returns <code>true</code> if <i>fix</i> is zero.
13439 def zero?; true || false; end
13440 ##
13441 # Returns <code>true</code> if <i>fix</i> is an odd number.
13442 def odd?; true || false; end
13443 ##
13444 # Returns <code>true</code> if <i>fix</i> is an even number.
13445 def even?; true || false; end
13446 ##
13447 # Returns the <code>Integer</code> equal to <i>int</i> + 1.
13448 # 
13449 #    1.next      #=> 2
13450 #    (-1).next   #=> 0
13451 def next; 0; end
13452 ##
13453 # Returns the <code>Integer</code> equal to <i>int</i> + 1.
13454 # 
13455 #    1.next      #=> 2
13456 #    (-1).next   #=> 0
13457 def succ; 0; end
13458 end
13459 
13460 ##
13461 # A Hash is a dictionary-like collection of unique keys and their values.
13462 # Also called associative arrays, they are similar to Arrays, but where an
13463 # Array uses integers as its index, a Hash allows you to use any object
13464 # type.
13465 # 
13466 # Hashes enumerate their values in the order that the corresponding keys
13467 # were inserted.
13468 # 
13469 # A Hash can be easily created by using its implicit form:
13470 # 
13471 #   grades = { "Jane Doe" => 10, "Jim Doe" => 6 }
13472 # 
13473 # Hashes allow an alternate syntax form when your keys are always symbols.
13474 # Instead of
13475 # 
13476 #   options = { :font_size => 10, :font_family => "Arial" }
13477 # 
13478 # You could write it as:
13479 # 
13480 #   options = { font_size: 10, font_family: "Arial" }
13481 # 
13482 # Each named key is a symbol you can access in hash:
13483 # 
13484 #   options[:font_size]  # => 10
13485 # 
13486 # A Hash can also be created through its ::new method:
13487 # 
13488 #   grades = Hash.new
13489 #   grades["Dorothy Doe"] = 9
13490 # 
13491 # Hashes have a <em>default value</em> that is returned when accessing
13492 # keys that do not exist in the hash. If no default is set +nil+ is used.
13493 # You can set the default value by sending it as an argument to Hash.new:
13494 # 
13495 #   grades = Hash.new(0)
13496 # 
13497 # Or by using the #default= method:
13498 # 
13499 #   grades = {"Timmy Doe" => 8}
13500 #   grades.default = 0
13501 # 
13502 # Accessing a value in a Hash requires using its key:
13503 # 
13504 #   puts grades["Jane Doe"] # => 10
13505 # 
13506 # === Common Uses
13507 # 
13508 # Hashes are an easy way to represent data structures, such as
13509 # 
13510 #   books         = {}
13511 #   books[:matz]  = "The Ruby Language"
13512 #   books[:black] = "The Well-Grounded Rubyist"
13513 # 
13514 # Hashes are also commonly used as a way to have named parameters in
13515 # functions. Note that no brackets are used below. If a hash is the last
13516 # argument on a method call, no braces are needed, thus creating a really
13517 # clean interface:
13518 # 
13519 #   Person.create(name: "John Doe", age: 27)
13520 # 
13521 #   def self.create(params)
13522 #     @name = params[:name]
13523 #     @age  = params[:age]
13524 #   end
13525 # 
13526 # === Hash Keys
13527 # 
13528 # Two objects refer to the same hash key when their <code>hash</code> value
13529 # is identical and the two objects are <code>eql?</code> to each other.
13530 # 
13531 # A user-defined class may be used as a hash key if the <code>hash</code>
13532 # and <code>eql?</code> methods are overridden to provide meaningful
13533 # behavior.  By default, separate instances refer to separate hash keys.
13534 # 
13535 # A typical implementation of <code>hash</code> is based on the
13536 # object's data while <code>eql?</code> is usually aliased to the overridden
13537 # <code>==</code> method:
13538 # 
13539 #   class Book
13540 #     attr_reader :author, :title
13541 # 
13542 #     def initialize(author, title)
13543 #       @author = author
13544 #       @title = title
13545 #     end
13546 # 
13547 #     def ==(other)
13548 #       self.class === other and
13549 #         other.author == @author and
13550 #         other.title == @title
13551 #     end
13552 # 
13553 #     alias eql? ==
13554 # 
13555 #     def hash
13556 #       @author.hash ^ @title.hash # XOR
13557 #     end
13558 #   end
13559 # 
13560 #   book1 = Book.new 'matz', 'Ruby in a Nutshell'
13561 #   book2 = Book.new 'matz', 'Ruby in a Nutshell'
13562 # 
13563 #   reviews = {}
13564 # 
13565 #   reviews[book1] = 'Great reference!'
13566 #   reviews[book2] = 'Nice and compact!'
13567 # 
13568 #   reviews.length #=> 1
13569 # 
13570 # See also Object#hash and Object#eql?
13571 class Hash < Object
13572 include Enumerable
13573 ##
13574 # Creates a new hash populated with the given objects. Equivalent to
13575 # the literal <code>{ <i>key</i> => <i>value</i>, ... }</code>. In the first
13576 # form, keys and values occur in pairs, so there must be an even number of arguments.
13577 # The second and third form take a single argument which is either
13578 # an array of key-value pairs or an object convertible to a hash.
13579 # 
13580 #    Hash["a", 100, "b", 200]             #=> {"a"=>100, "b"=>200}
13581 #    Hash[ [ ["a", 100], ["b", 200] ] ]   #=> {"a"=>100, "b"=>200}
13582 #    Hash["a" => 100, "b" => 200]         #=> {"a"=>100, "b"=>200}
13583 def self.[]; Object.new; end
13584 ##
13585 # Try to convert <i>obj</i> into a hash, using to_hash method.
13586 # Returns converted hash or nil if <i>obj</i> cannot be converted
13587 # for any reason.
13588 # 
13589 #    Hash.try_convert({1=>2})   # => {1=>2}
13590 #    Hash.try_convert("1=>2")   # => nil
13591 def self.try_convert(obj); {} || nil; end
13592 ##
13593 # Returns a new, empty hash. If this hash is subsequently accessed by
13594 # a key that doesn't correspond to a hash entry, the value returned
13595 # depends on the style of <code>new</code> used to create the hash. In
13596 # the first form, the access returns <code>nil</code>. If
13597 # <i>obj</i> is specified, this single object will be used for
13598 # all <em>default values</em>. If a block is specified, it will be
13599 # called with the hash object and the key, and should return the
13600 # default value. It is the block's responsibility to store the value
13601 # in the hash if required.
13602 # 
13603 #    h = Hash.new("Go Fish")
13604 #    h["a"] = 100
13605 #    h["b"] = 200
13606 #    h["a"]           #=> 100
13607 #    h["c"]           #=> "Go Fish"
13608 #    # The following alters the single default object
13609 #    h["c"].upcase!   #=> "GO FISH"
13610 #    h["d"]           #=> "GO FISH"
13611 #    h.keys           #=> ["a", "b"]
13612 # 
13613 #    # While this creates a new default object each time
13614 #    h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
13615 #    h["c"]           #=> "Go Fish: c"
13616 #    h["c"].upcase!   #=> "GO FISH: C"
13617 #    h["d"]           #=> "Go Fish: d"
13618 #    h.keys           #=> ["c", "d"]
13619 def self.new; end
13620 ##
13621 # Rebuilds the hash based on the current hash values for each key. If
13622 # values of key objects have changed since they were inserted, this
13623 # method will reindex <i>hsh</i>. If <code>Hash#rehash</code> is
13624 # called while an iterator is traversing the hash, an
13625 # <code>RuntimeError</code> will be raised in the iterator.
13626 # 
13627 #    a = [ "a", "b" ]
13628 #    c = [ "c", "d" ]
13629 #    h = { a => 100, c => 300 }
13630 #    h[a]       #=> 100
13631 #    a[0] = "z"
13632 #    h[a]       #=> nil
13633 #    h.rehash   #=> {["z", "b"]=>100, ["c", "d"]=>300}
13634 #    h[a]       #=> 100
13635 def rehash; {}; end
13636 ##
13637 # Returns +self+.
13638 def to_hash; {}; end
13639 ##
13640 # Returns +self+. If called on a subclass of Hash, converts
13641 # the receiver to a Hash object.
13642 def to_h; {}; end
13643 ##
13644 # Converts <i>hsh</i> to a nested array of <code>[</code> <i>key,
13645 # value</i> <code>]</code> arrays.
13646 # 
13647 #    h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300  }
13648 #    h.to_a   #=> [["c", 300], ["a", 100], ["d", 400]]
13649 def to_a; []; end
13650 ##
13651 # Return the contents of this hash as a string.
13652 # 
13653 #     h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300  }
13654 #     h.to_s   #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}"
13655 def to_s; ''; end
13656 ##
13657 # Return the contents of this hash as a string.
13658 # 
13659 #     h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300  }
13660 #     h.to_s   #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}"
13661 def inspect; ''; end
13662 ##
13663 # Equality---Two hashes are equal if they each contain the same number
13664 # of keys and if each key-value pair is equal to (according to
13665 # <code>Object#==</code>) the corresponding elements in the other
13666 # hash.
13667 # 
13668 #    h1 = { "a" => 1, "c" => 2 }
13669 #    h2 = { 7 => 35, "c" => 2, "a" => 1 }
13670 #    h3 = { "a" => 1, "c" => 2, 7 => 35 }
13671 #    h4 = { "a" => 1, "d" => 2, "f" => 35 }
13672 #    h1 == h2   #=> false
13673 #    h2 == h3   #=> true
13674 #    h3 == h4   #=> false
13675 def ==; true || false; end
13676 ##
13677 # Compute a hash-code for this hash. Two hashes with the same content
13678 # will have the same hash code (and will compare using <code>eql?</code>).
13679 def hash; 0; end
13680 ##
13681 # Returns <code>true</code> if <i>hash</i> and <i>other</i> are
13682 # both hashes with the same content.
13683 def eql?(other); true || false; end
13684 ##
13685 # Returns a value from the hash for the given key. If the key can't be
13686 # found, there are several options: With no other arguments, it will
13687 # raise an <code>KeyError</code> exception; if <i>default</i> is
13688 # given, then that will be returned; if the optional code block is
13689 # specified, then that will be run and its result returned.
13690 # 
13691 #    h = { "a" => 100, "b" => 200 }
13692 #    h.fetch("a")                            #=> 100
13693 #    h.fetch("z", "go fish")                 #=> "go fish"
13694 #    h.fetch("z") { |el| "go fish, #{el}"}   #=> "go fish, z"
13695 # 
13696 # The following example shows that an exception is raised if the key
13697 # is not found and a default value is not supplied.
13698 # 
13699 #    h = { "a" => 100, "b" => 200 }
13700 #    h.fetch("z")
13701 # 
13702 # <em>produces:</em>
13703 # 
13704 #    prog.rb:2:in `fetch': key not found (KeyError)
13705 #     from prog.rb:2
13706 def fetch(key  , default=0); Object.new; end
13707 ##
13708 # Element Assignment---Associates the value given by
13709 # <i>value</i> with the key given by <i>key</i>.
13710 # <i>key</i> should not have its value changed while it is in
13711 # use as a key (a <code>String</code> passed as a key will be
13712 # duplicated and frozen).
13713 # 
13714 #    h = { "a" => 100, "b" => 200 }
13715 #    h["a"] = 9
13716 #    h["c"] = 4
13717 #    h   #=> {"a"=>9, "b"=>200, "c"=>4}
13718 def []=; Object.new; end
13719 ##
13720 # Element Assignment---Associates the value given by
13721 # <i>value</i> with the key given by <i>key</i>.
13722 # <i>key</i> should not have its value changed while it is in
13723 # use as a key (a <code>String</code> passed as a key will be
13724 # duplicated and frozen).
13725 # 
13726 #    h = { "a" => 100, "b" => 200 }
13727 #    h["a"] = 9
13728 #    h["c"] = 4
13729 #    h   #=> {"a"=>9, "b"=>200, "c"=>4}
13730 def store(key, value); Object.new; end
13731 ##
13732 # Returns the default value, the value that would be returned by
13733 # <i>hsh</i>[<i>key</i>] if <i>key</i> did not exist in <i>hsh</i>.
13734 # See also <code>Hash::new</code> and <code>Hash#default=</code>.
13735 # 
13736 #    h = Hash.new                            #=> {}
13737 #    h.default                               #=> nil
13738 #    h.default(2)                            #=> nil
13739 # 
13740 #    h = Hash.new("cat")                     #=> {}
13741 #    h.default                               #=> "cat"
13742 #    h.default(2)                            #=> "cat"
13743 # 
13744 #    h = Hash.new {|h,k| h[k] = k.to_i*10}   #=> {}
13745 #    h.default                               #=> nil
13746 #    h.default(2)                            #=> 20
13747 def default(key=null); Object.new; end
13748 ##
13749 # Sets the default value, the value returned for a key that does not
13750 # exist in the hash. It is not possible to set the default to a
13751 # <code>Proc</code> that will be executed on each key lookup.
13752 # 
13753 #    h = { "a" => 100, "b" => 200 }
13754 #    h.default = "Go fish"
13755 #    h["a"]     #=> 100
13756 #    h["z"]     #=> "Go fish"
13757 #    # This doesn't do what you might hope...
13758 #    h.default = proc do |hash, key|
13759 #      hash[key] = key + key
13760 #    end
13761 #    h[2]       #=> #<Proc:0x401b3948@-:6>
13762 #    h["cat"]   #=> #<Proc:0x401b3948@-:6>
13763 def default= obj; Object.new; end
13764 ##
13765 # If <code>Hash::new</code> was invoked with a block, return that
13766 # block, otherwise return <code>nil</code>.
13767 # 
13768 #    h = Hash.new {|h,k| h[k] = k*k }   #=> {}
13769 #    p = h.default_proc                 #=> #<Proc:0x401b3d08@-:1>
13770 #    a = []                             #=> []
13771 #    p.call(a, 2)
13772 #    a                                  #=> [nil, nil, 4]
13773 def default_proc; Object.new; end
13774 ##
13775 # Sets the default proc to be executed on each failed key lookup.
13776 # 
13777 #    h.default_proc = proc do |hash, key|
13778 #      hash[key] = key + key
13779 #    end
13780 #    h[2]       #=> 4
13781 #    h["cat"]   #=> "catcat"
13782 def default_proc= proc_or_nil; end
13783 ##
13784 # Returns the key of an occurrence of a given value. If the value is
13785 # not found, returns <code>nil</code>.
13786 # 
13787 #    h = { "a" => 100, "b" => 200, "c" => 300, "d" => 300 }
13788 #    h.key(200)   #=> "b"
13789 #    h.key(300)   #=> "c"
13790 #    h.key(999)   #=> nil
13791 def key(value); Object.new; end
13792 ##
13793 # Returns the number of key-value pairs in the hash.
13794 # 
13795 #    h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
13796 #    h.length        #=> 4
13797 #    h.delete("a")   #=> 200
13798 #    h.length        #=> 3
13799 def length; 0; end
13800 ##
13801 # Returns the number of key-value pairs in the hash.
13802 # 
13803 #    h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
13804 #    h.length        #=> 4
13805 #    h.delete("a")   #=> 200
13806 #    h.length        #=> 3
13807 def size; 0; end
13808 ##
13809 # Returns <code>true</code> if <i>hsh</i> contains no key-value pairs.
13810 # 
13811 #    {}.empty?   #=> true
13812 def empty?; true || false; end
13813 ##
13814 # Calls <i>block</i> once for each key in <i>hsh</i>, passing the
13815 # value as a parameter.
13816 # 
13817 # If no block is given, an enumerator is returned instead.
13818 # 
13819 #    h = { "a" => 100, "b" => 200 }
13820 #    h.each_value {|value| puts value }
13821 # 
13822 # <em>produces:</em>
13823 # 
13824 #    100
13825 #    200
13826 def each_value(&block); Enumerator.new; end
13827 ##
13828 # Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
13829 # as a parameter.
13830 # 
13831 # If no block is given, an enumerator is returned instead.
13832 # 
13833 #    h = { "a" => 100, "b" => 200 }
13834 #    h.each_key {|key| puts key }
13835 # 
13836 # <em>produces:</em>
13837 # 
13838 #    a
13839 #    b
13840 def each_key(&block); Enumerator.new; end
13841 ##
13842 # Calls <i>block</i> once for each key in <i>hsh</i>, passing the key-value
13843 # pair as parameters.
13844 # 
13845 # If no block is given, an enumerator is returned instead.
13846 # 
13847 #    h = { "a" => 100, "b" => 200 }
13848 #    h.each {|key, value| puts "#{key} is #{value}" }
13849 # 
13850 # <em>produces:</em>
13851 # 
13852 #    a is 100
13853 #    b is 200
13854 def each(&block); Enumerator.new; end
13855 ##
13856 # Calls <i>block</i> once for each key in <i>hsh</i>, passing the key-value
13857 # pair as parameters.
13858 # 
13859 # If no block is given, an enumerator is returned instead.
13860 # 
13861 #    h = { "a" => 100, "b" => 200 }
13862 #    h.each {|key, value| puts "#{key} is #{value}" }
13863 # 
13864 # <em>produces:</em>
13865 # 
13866 #    a is 100
13867 #    b is 200
13868 def each_pair(&block); Enumerator.new; end
13869 ##
13870 # Returns a new array populated with the keys from this hash. See also
13871 # <code>Hash#values</code>.
13872 # 
13873 #    h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 }
13874 #    h.keys   #=> ["a", "b", "c", "d"]
13875 def keys; []; end
13876 ##
13877 # Returns a new array populated with the values from <i>hsh</i>. See
13878 # also <code>Hash#keys</code>.
13879 # 
13880 #    h = { "a" => 100, "b" => 200, "c" => 300 }
13881 #    h.values   #=> [100, 200, 300]
13882 def values; []; end
13883 ##
13884 # Return an array containing the values associated with the given keys.
13885 # Also see <code>Hash.select</code>.
13886 # 
13887 #   h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
13888 #   h.values_at("cow", "cat")  #=> ["bovine", "feline"]
13889 def values_at(); []; end
13890 ##
13891 # Removes a key-value pair from <i>hsh</i> and returns it as the
13892 # two-item array <code>[</code> <i>key, value</i> <code>]</code>, or
13893 # the hash's default value if the hash is empty.
13894 # 
13895 #    h = { 1 => "a", 2 => "b", 3 => "c" }
13896 #    h.shift   #=> [1, "a"]
13897 #    h         #=> {2=>"b", 3=>"c"}
13898 def shift; [] || Object.new; end
13899 ##
13900 # Deletes the key-value pair and returns the value from <i>hsh</i> whose
13901 # key is equal to <i>key</i>. If the key is not found, returns the
13902 # <em>default value</em>. If the optional code block is given and the
13903 # key is not found, pass in the key and return the result of
13904 # <i>block</i>.
13905 # 
13906 #    h = { "a" => 100, "b" => 200 }
13907 #    h.delete("a")                              #=> 100
13908 #    h.delete("z")                              #=> nil
13909 #    h.delete("z") { |el| "#{el} not found" }   #=> "z not found"
13910 def delete(key); Object.new; end
13911 ##
13912 # Deletes every key-value pair from <i>hsh</i> for which <i>block</i>
13913 # evaluates to <code>true</code>.
13914 # 
13915 # If no block is given, an enumerator is returned instead.
13916 # 
13917 #    h = { "a" => 100, "b" => 200, "c" => 300 }
13918 #    h.delete_if {|key, value| key >= "b" }   #=> {"a"=>100}
13919 def delete_if(&block); Enumerator.new; end
13920 ##
13921 # Deletes every key-value pair from <i>hsh</i> for which <i>block</i>
13922 # evaluates to false.
13923 # 
13924 # If no block is given, an enumerator is returned instead.
13925 def keep_if(&block); Enumerator.new; end
13926 ##
13927 # Returns a new hash consisting of entries for which the block returns true.
13928 # 
13929 # If no block is given, an enumerator is returned instead.
13930 # 
13931 #    h = { "a" => 100, "b" => 200, "c" => 300 }
13932 #    h.select {|k,v| k > "a"}  #=> {"b" => 200, "c" => 300}
13933 #    h.select {|k,v| v < 200}  #=> {"a" => 100}
13934 def select(&block); Enumerator.new; end
13935 ##
13936 # Equivalent to <code>Hash#keep_if</code>, but returns
13937 # <code>nil</code> if no changes were made.
13938 def select!(&block); Enumerator.new; end
13939 ##
13940 # Same as <code>Hash#delete_if</code>, but works on (and returns) a
13941 # copy of the <i>hsh</i>. Equivalent to
13942 # <code><i>hsh</i>.dup.delete_if</code>.
13943 def reject(&block); Enumerator.new; end
13944 ##
13945 # Equivalent to <code>Hash#delete_if</code>, but returns
13946 # <code>nil</code> if no changes were made.
13947 def reject!(&block); Enumerator.new; end
13948 ##
13949 # Removes all key-value pairs from <i>hsh</i>.
13950 # 
13951 #    h = { "a" => 100, "b" => 200 }   #=> {"a"=>100, "b"=>200}
13952 #    h.clear                          #=> {}
13953 def clear; {}; end
13954 ##
13955 # Returns a new hash created by using <i>hsh</i>'s values as keys, and
13956 # the keys as values.
13957 # 
13958 #    h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
13959 #    h.invert   #=> {0=>"a", 100=>"m", 200=>"d", 300=>"y"}
13960 def invert; {}; end
13961 ##
13962 # Adds the contents of _other_hash_ to _hsh_.  If no block is specified,
13963 # entries with duplicate keys are overwritten with the values from
13964 # _other_hash_, otherwise the value of each duplicate key is determined by
13965 # calling the block with the key, its value in _hsh_ and its value in
13966 # _other_hash_.
13967 # 
13968 #    h1 = { "a" => 100, "b" => 200 }
13969 #    h2 = { "b" => 254, "c" => 300 }
13970 #    h1.merge!(h2)   #=> {"a"=>100, "b"=>254, "c"=>300}
13971 # 
13972 #    h1 = { "a" => 100, "b" => 200 }
13973 #    h2 = { "b" => 254, "c" => 300 }
13974 #    h1.merge!(h2) { |key, v1, v2| v1 }
13975 #                    #=> {"a"=>100, "b"=>200, "c"=>300}
13976 def merge!(other_hash); {}; end
13977 ##
13978 # Adds the contents of _other_hash_ to _hsh_.  If no block is specified,
13979 # entries with duplicate keys are overwritten with the values from
13980 # _other_hash_, otherwise the value of each duplicate key is determined by
13981 # calling the block with the key, its value in _hsh_ and its value in
13982 # _other_hash_.
13983 # 
13984 #    h1 = { "a" => 100, "b" => 200 }
13985 #    h2 = { "b" => 254, "c" => 300 }
13986 #    h1.merge!(h2)   #=> {"a"=>100, "b"=>254, "c"=>300}
13987 # 
13988 #    h1 = { "a" => 100, "b" => 200 }
13989 #    h2 = { "b" => 254, "c" => 300 }
13990 #    h1.merge!(h2) { |key, v1, v2| v1 }
13991 #                    #=> {"a"=>100, "b"=>200, "c"=>300}
13992 def update(other_hash); {}; end
13993 ##
13994 # Replaces the contents of <i>hsh</i> with the contents of
13995 # <i>other_hash</i>.
13996 # 
13997 #    h = { "a" => 100, "b" => 200 }
13998 #    h.replace({ "c" => 300, "d" => 400 })   #=> {"c"=>300, "d"=>400}
13999 def replace(other_hash); {}; end
14000 ##
14001 # Returns a new hash containing the contents of <i>other_hash</i> and
14002 # the contents of <i>hsh</i>. If no block is specified, the value for
14003 # entries with duplicate keys will be that of <i>other_hash</i>. Otherwise
14004 # the value for each duplicate key is determined by calling the block
14005 # with the key, its value in <i>hsh</i> and its value in <i>other_hash</i>.
14006 # 
14007 #    h1 = { "a" => 100, "b" => 200 }
14008 #    h2 = { "b" => 254, "c" => 300 }
14009 #    h1.merge(h2)   #=> {"a"=>100, "b"=>254, "c"=>300}
14010 #    h1.merge(h2){|key, oldval, newval| newval - oldval}
14011 #                   #=> {"a"=>100, "b"=>54,  "c"=>300}
14012 #    h1             #=> {"a"=>100, "b"=>200}
14013 def merge(other_hash); {}; end
14014 ##
14015 # Searches through the hash comparing _obj_ with the key using <code>==</code>.
14016 # Returns the key-value pair (two elements array) or +nil+
14017 # if no match is found.  See <code>Array#assoc</code>.
14018 # 
14019 #    h = {"colors"  => ["red", "blue", "green"],
14020 #         "letters" => ["a", "b", "c" ]}
14021 #    h.assoc("letters")  #=> ["letters", ["a", "b", "c"]]
14022 #    h.assoc("foo")      #=> nil
14023 def assoc(obj); [] || nil; end
14024 ##
14025 # Searches through the hash comparing _obj_ with the value using <code>==</code>.
14026 # Returns the first key-value pair (two-element array) that matches. See
14027 # also <code>Array#rassoc</code>.
14028 # 
14029 #    a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
14030 #    a.rassoc("two")    #=> [2, "two"]
14031 #    a.rassoc("four")   #=> nil
14032 def rassoc(obj); [] || nil; end
14033 ##
14034 # Returns a new array that is a one-dimensional flattening of this
14035 # hash. That is, for every key or value that is an array, extract
14036 # its elements into the new array.  Unlike Array#flatten, this
14037 # method does not flatten recursively by default.  The optional
14038 # <i>level</i> argument determines the level of recursion to flatten.
14039 # 
14040 #    a =  {1=> "one", 2 => [2,"two"], 3 => "three"}
14041 #    a.flatten    # => [1, "one", 2, [2, "two"], 3, "three"]
14042 #    a.flatten(2) # => [1, "one", 2, 2, "two", 3, "three"]
14043 def flatten; []; end
14044 ##
14045 # Returns <code>true</code> if the given key is present in <i>hsh</i>.
14046 # 
14047 #    h = { "a" => 100, "b" => 200 }
14048 #    h.has_key?("a")   #=> true
14049 #    h.has_key?("z")   #=> false
14050 def has_key?(key); true || false; end
14051 ##
14052 # Returns <code>true</code> if the given key is present in <i>hsh</i>.
14053 # 
14054 #    h = { "a" => 100, "b" => 200 }
14055 #    h.has_key?("a")   #=> true
14056 #    h.has_key?("z")   #=> false
14057 def include?(key); true || false; end
14058 ##
14059 # Returns <code>true</code> if the given key is present in <i>hsh</i>.
14060 # 
14061 #    h = { "a" => 100, "b" => 200 }
14062 #    h.has_key?("a")   #=> true
14063 #    h.has_key?("z")   #=> false
14064 def key?(key); true || false; end
14065 ##
14066 # Returns <code>true</code> if the given key is present in <i>hsh</i>.
14067 # 
14068 #    h = { "a" => 100, "b" => 200 }
14069 #    h.has_key?("a")   #=> true
14070 #    h.has_key?("z")   #=> false
14071 def member?(key); true || false; end
14072 ##
14073 # Returns <code>true</code> if the given value is present for some key
14074 # in <i>hsh</i>.
14075 # 
14076 #    h = { "a" => 100, "b" => 200 }
14077 #    h.has_value?(100)   #=> true
14078 #    h.has_value?(999)   #=> false
14079 def has_value?(value); true || false; end
14080 ##
14081 # Returns <code>true</code> if the given value is present for some key
14082 # in <i>hsh</i>.
14083 # 
14084 #    h = { "a" => 100, "b" => 200 }
14085 #    h.has_value?(100)   #=> true
14086 #    h.has_value?(999)   #=> false
14087 def value?(value); true || false; end
14088 ##
14089 # Makes <i>hsh</i> compare its keys by their identity, i.e. it
14090 # will consider exact same objects as same keys.
14091 # 
14092 #    h1 = { "a" => 100, "b" => 200, :c => "c" }
14093 #    h1["a"]        #=> 100
14094 #    h1.compare_by_identity
14095 #    h1.compare_by_identity? #=> true
14096 #    h1["a"]        #=> nil  # different objects.
14097 #    h1[:c]         #=> "c"  # same symbols are all same.
14098 def compare_by_identity; {}; end
14099 ##
14100 # Returns <code>true</code> if <i>hsh</i> will compare its keys by
14101 # their identity.  Also see <code>Hash#compare_by_identity</code>.
14102 def compare_by_identity?; true || false; end
14103 end
14104 
14105 ##
14106 # ENV is a hash-like accessor for environment variables.
14107 class ENV < Object
14108 ##
14109 # Retrieves the +value+ for environment variable +name+ as a String.  Returns
14110 # +nil+ if the named variable does not exist.
14111 def self.[]; Object.new; end
14112 ##
14113 # Retrieves the environment variable +name+.
14114 # 
14115 # If the given name does not exist and neither +default+ nor a block a
14116 # provided an IndexError is raised.  If a block is given it is called with
14117 # the missing name to provide a value.  If a default value is given it will
14118 # be returned when no block is given.
14119 def self.fetch(name); Object.new; end
14120 ##
14121 # Sets the environment variable +name+ to +value+.  If the value given is
14122 # +nil+ the environment variable is deleted.
14123 def self.[]=; end
14124 ##
14125 # Sets the environment variable +name+ to +value+.  If the value given is
14126 # +nil+ the environment variable is deleted.
14127 def self.store(name, value); Object.new; end
14128 ##
14129 # Yields each environment variable +name+ and +value+.
14130 # 
14131 # If no block is given an Enumerator is returned.
14132 def self.each(&block); Enumerator.new; end
14133 ##
14134 # Yields each environment variable +name+ and +value+.
14135 # 
14136 # If no block is given an Enumerator is returned.
14137 def self.each_pair(&block); Enumerator.new; end
14138 ##
14139 # Yields each environment variable name.
14140 # 
14141 # An Enumerator is returned if no block is given.
14142 def self.each_key(&block); Enumerator.new; end
14143 ##
14144 # Yields each environment variable +value+.
14145 # 
14146 # An Enumerator is returned if no block was given.
14147 def self.each_value(&block); Enumerator.new; end
14148 ##
14149 # Deletes the environment variable with +name+ and returns the value of the
14150 # variable.  If a block is given it will be called when the named environment
14151 # does not exist.
14152 def self.delete(name); Object.new; end
14153 ##
14154 # Deletes every environment variable for which the block evaluates to +true+.
14155 # 
14156 # If no block is given an enumerator is returned instead.
14157 def self.delete_if(&block); Enumerator.new; end
14158 ##
14159 # Deletes every environment variable where the block evaluates to +false+.
14160 # 
14161 # Returns an enumerator if no block was given.
14162 def self.keep_if(&block); Enumerator.new; end
14163 ##
14164 # Removes every environment variable.
14165 def self.clear; end
14166 ##
14167 # Same as ENV#delete_if, but works on (and returns) a copy of the
14168 # environment.
14169 def self.reject(&block); Enumerator.new; end
14170 ##
14171 # Equivalent to ENV#delete_if but returns +nil+ if no changes were made.
14172 # 
14173 # Returns an Enumerator if no block was given.
14174 def self.reject!(&block); Enumerator.new; end
14175 ##
14176 # Returns a copy of the environment for entries where the block returns true.
14177 # 
14178 # Returns an Enumerator if no block was given.
14179 def self.select(&block); Enumerator.new; end
14180 ##
14181 # Equivalent to ENV#keep_if but returns +nil+ if no changes were made.
14182 def self.select!(&block); Enumerator.new; end
14183 ##
14184 # Removes an environment variable name-value pair from ENV and returns it as
14185 # an Array.  Returns +nil+ if when the environment is empty.
14186 def self.shift; [] || nil; end
14187 ##
14188 # Returns a new hash created by using environment variable names as values
14189 # and values as names.
14190 def self.invert; {}; end
14191 ##
14192 # Replaces the contents of the environment variables with the contents of
14193 # +hash+.
14194 def self.replace(hash); ENV; end
14195 ##
14196 # Adds the contents of +hash+ to the environment variables.  If no block is
14197 # specified entries with duplicate keys are overwritten, otherwise the value
14198 # of each duplicate name is determined by calling the block with the key, its
14199 # value from the environment and its value from the hash.
14200 def self.update(hash); {}; end
14201 ##
14202 # Returns the contents of the environment as a String.
14203 def self.inspect; ''; end
14204 ##
14205 # Re-hashing the environment variables does nothing.  It is provided for
14206 # compatibility with Hash.
14207 def self.rehash; end
14208 ##
14209 # Converts the environment variables into an array of names and value arrays.
14210 # 
14211 #   ENV.to_a # => [["TERM" => "xterm-color"], ["SHELL" => "/bin/bash"], ...]
14212 def self.to_a; []; end
14213 ##
14214 # Returns "ENV"
14215 def self.to_s; ENV; end
14216 ##
14217 # Returns the name of the environment variable with +value+.  If the value is
14218 # not found +nil+ is returned.
14219 def self.key(value); ''; end
14220 ##
14221 # Deprecated method that is equivalent to ENV.key
14222 def self.index(value); Object.new; end
14223 ##
14224 # Returns the number of environment variables.
14225 def self.length; end
14226 ##
14227 # Returns the number of environment variables.
14228 def self.size; end
14229 ##
14230 # Returns true when there are no environment variables
14231 def self.empty?; true || false; end
14232 ##
14233 # Returns every environment variable name in an Array
14234 def self.keys; []; end
14235 ##
14236 # Returns every environment variable value as an Array
14237 def self.values; []; end
14238 ##
14239 # Returns an array containing the environment variable values associated with
14240 # the given names.  See also ENV.select.
14241 def self.values_at(); []; end
14242 ##
14243 # Returns +true+ if there is an environment variable with the given +name+.
14244 def self.key?(name); true || false; end
14245 ##
14246 # Returns +true+ if there is an environment variable with the given +name+.
14247 def self.include?(name); true || false; end
14248 ##
14249 # Returns +true+ if there is an environment variable with the given +name+.
14250 def self.has_key?(name); true || false; end
14251 ##
14252 # Returns +true+ if there is an environment variable with the given +name+.
14253 def self.member?(name); true || false; end
14254 ##
14255 # Returns +true+ if there is an environment variable with the given +value+.
14256 def self.value?(value); true || false; end
14257 ##
14258 # Returns +true+ if there is an environment variable with the given +value+.
14259 def self.has_value?(value); true || false; end
14260 ##
14261 # Creates a hash with a copy of the environment variables.
14262 def self.to_hash; {}; end
14263 ##
14264 # Creates a hash with a copy of the environment variables.
14265 def self.to_h; {}; end
14266 ##
14267 # Returns an Array of the name and value of the environment variable with
14268 # +name+ or +nil+ if the name cannot be found.
14269 def self.assoc(name); [] || nil; end
14270 ##
14271 # Returns an Array of the name and value of the environment variable with
14272 # +value+ or +nil+ if the value cannot be found.
14273 def self.rassoc(value); end
14274 end
14275 
14276 ##
14277 # Objects of class <code>Dir</code> are directory streams representing
14278 # directories in the underlying file system. They provide a variety of
14279 # ways to list directories and their contents. See also
14280 # <code>File</code>.
14281 # 
14282 # The directory used in these examples contains the two regular files
14283 # (<code>config.h</code> and <code>main.rb</code>), the parent
14284 # directory (<code>..</code>), and the directory itself
14285 # (<code>.</code>).
14286 class Dir < Object
14287 include Enumerable
14288 ##
14289 # With no block, <code>open</code> is a synonym for
14290 # <code>Dir::new</code>. If a block is present, it is passed
14291 # <i>aDir</i> as a parameter. The directory is closed at the end of
14292 # the block, and <code>Dir::open</code> returns the value of the
14293 # block.
14294 def self.open( string ); Object.new; end
14295 ##
14296 # Calls the block once for each entry in the named directory, passing
14297 # the filename of each entry as a parameter to the block.
14298 # 
14299 # If no block is given, an enumerator is returned instead.
14300 # 
14301 #    Dir.foreach("testdir") {|x| puts "Got #{x}" }
14302 # 
14303 # <em>produces:</em>
14304 # 
14305 #    Got .
14306 #    Got ..
14307 #    Got config.h
14308 #    Got main.rb
14309 def self.foreach( dirname , &block); Enumerator.new; end
14310 ##
14311 # Returns an array containing all of the filenames in the given
14312 # directory. Will raise a <code>SystemCallError</code> if the named
14313 # directory doesn't exist.
14314 # 
14315 #    Dir.entries("testdir")   #=> [".", "..", "config.h", "main.rb"]
14316 def self.entries( dirname ); []; end
14317 ##
14318 # Returns a new directory object for the named directory.
14319 def self.new( string ); end
14320 ##
14321 # Returns the path parameter passed to <em>dir</em>'s constructor.
14322 # 
14323 #    d = Dir.new("..")
14324 #    d.path   #=> ".."
14325 def path; '' || nil; end
14326 ##
14327 # Return a string describing this Dir object.
14328 def inspect; ''; end
14329 ##
14330 # Reads the next entry from <em>dir</em> and returns it as a string.
14331 # Returns <code>nil</code> at the end of the stream.
14332 # 
14333 #    d = Dir.new("testdir")
14334 #    d.read   #=> "."
14335 #    d.read   #=> ".."
14336 #    d.read   #=> "config.h"
14337 def read; '' || nil; end
14338 ##
14339 # Calls the block once for each entry in this directory, passing the
14340 # filename of each entry as a parameter to the block.
14341 # 
14342 # If no block is given, an enumerator is returned instead.
14343 # 
14344 #    d = Dir.new("testdir")
14345 #    d.each  {|x| puts "Got #{x}" }
14346 # 
14347 # <em>produces:</em>
14348 # 
14349 #    Got .
14350 #    Got ..
14351 #    Got config.h
14352 #    Got main.rb
14353 def each(&block); Enumerator.new; end
14354 ##
14355 # Repositions <em>dir</em> to the first entry.
14356 # 
14357 #    d = Dir.new("testdir")
14358 #    d.read     #=> "."
14359 #    d.rewind   #=> #<Dir:0x401b3fb0>
14360 #    d.read     #=> "."
14361 def rewind; Dir.new; end
14362 ##
14363 # Returns the current position in <em>dir</em>. See also
14364 # <code>Dir#seek</code>.
14365 # 
14366 #    d = Dir.new("testdir")
14367 #    d.tell   #=> 0
14368 #    d.read   #=> "."
14369 #    d.tell   #=> 12
14370 def pos; 0; end
14371 ##
14372 # Returns the current position in <em>dir</em>. See also
14373 # <code>Dir#seek</code>.
14374 # 
14375 #    d = Dir.new("testdir")
14376 #    d.tell   #=> 0
14377 #    d.read   #=> "."
14378 #    d.tell   #=> 12
14379 def tell; 0; end
14380 ##
14381 # Seeks to a particular location in <em>dir</em>. <i>integer</i>
14382 # must be a value returned by <code>Dir#tell</code>.
14383 # 
14384 #    d = Dir.new("testdir")   #=> #<Dir:0x401b3c40>
14385 #    d.read                   #=> "."
14386 #    i = d.tell               #=> 12
14387 #    d.read                   #=> ".."
14388 #    d.seek(i)                #=> #<Dir:0x401b3c40>
14389 #    d.read                   #=> ".."
14390 def seek( integer ); Dir.new; end
14391 ##
14392 # Closes the directory stream. Any further attempts to access
14393 # <em>dir</em> will raise an <code>IOError</code>.
14394 # 
14395 #    d = Dir.new("testdir")
14396 #    d.close   #=> nil
14397 def close; end
14398 ##
14399 # Changes the current working directory of the process to the given
14400 # string. When called without an argument, changes the directory to
14401 # the value of the environment variable <code>HOME</code>, or
14402 # <code>LOGDIR</code>. <code>SystemCallError</code> (probably
14403 # <code>Errno::ENOENT</code>) if the target directory does not exist.
14404 # 
14405 # If a block is given, it is passed the name of the new current
14406 # directory, and the block is executed with that as the current
14407 # directory. The original working directory is restored when the block
14408 # exits. The return value of <code>chdir</code> is the value of the
14409 # block. <code>chdir</code> blocks can be nested, but in a
14410 # multi-threaded program an error will be raised if a thread attempts
14411 # to open a <code>chdir</code> block while another thread has one
14412 # open.
14413 # 
14414 #    Dir.chdir("/var/spool/mail")
14415 #    puts Dir.pwd
14416 #    Dir.chdir("/tmp") do
14417 #      puts Dir.pwd
14418 #      Dir.chdir("/usr") do
14419 #        puts Dir.pwd
14420 #      end
14421 #      puts Dir.pwd
14422 #    end
14423 #    puts Dir.pwd
14424 # 
14425 # <em>produces:</em>
14426 # 
14427 #    /var/spool/mail
14428 #    /tmp
14429 #    /usr
14430 #    /tmp
14431 #    /var/spool/mail
14432 def self.chdir(string=0); Object.new; end
14433 ##
14434 # Returns the path to the current working directory of this process as
14435 # a string.
14436 # 
14437 #    Dir.chdir("/tmp")   #=> 0
14438 #    Dir.getwd           #=> "/tmp"
14439 def self.getwd; ''; end
14440 ##
14441 # Returns the path to the current working directory of this process as
14442 # a string.
14443 # 
14444 #    Dir.chdir("/tmp")   #=> 0
14445 #    Dir.getwd           #=> "/tmp"
14446 def self.pwd; ''; end
14447 ##
14448 # Changes this process's idea of the file system root. Only a
14449 # privileged process may make this call. Not available on all
14450 # platforms. On Unix systems, see <code>chroot(2)</code> for more
14451 # information.
14452 def self.chroot( string ); 0; end
14453 ##
14454 # Makes a new directory named by <i>string</i>, with permissions
14455 # specified by the optional parameter <i>anInteger</i>. The
14456 # permissions may be modified by the value of
14457 # <code>File::umask</code>, and are ignored on NT. Raises a
14458 # <code>SystemCallError</code> if the directory cannot be created. See
14459 # also the discussion of permissions in the class documentation for
14460 # <code>File</code>.
14461 # 
14462 #   Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
14463 def self.mkdir( string  , integer=0); 0; end
14464 ##
14465 # Deletes the named directory. Raises a subclass of
14466 # <code>SystemCallError</code> if the directory isn't empty.
14467 def self.delete( string ); 0; end
14468 ##
14469 # Deletes the named directory. Raises a subclass of
14470 # <code>SystemCallError</code> if the directory isn't empty.
14471 def self.rmdir( string ); 0; end
14472 ##
14473 # Deletes the named directory. Raises a subclass of
14474 # <code>SystemCallError</code> if the directory isn't empty.
14475 def self.unlink( string ); 0; end
14476 ##
14477 # Returns the home directory of the current user or the named user
14478 # if given.
14479 def self.home(); ''; end
14480 ##
14481 # Returns the filenames found by expanding <i>pattern</i> which is
14482 # an +Array+ of the patterns or the pattern +String+, either as an
14483 # <i>array</i> or as parameters to the block. Note that this pattern
14484 # is not a regexp (it's closer to a shell glob). See
14485 # <code>File::fnmatch</code> for the meaning of the <i>flags</i>
14486 # parameter. Note that case sensitivity depends on your system (so
14487 # <code>File::FNM_CASEFOLD</code> is ignored), as does the order
14488 # in which the results are returned.
14489 # 
14490 # <code>*</code>::        Matches any file. Can be restricted by
14491 #                         other values in the glob. <code>*</code>
14492 #                         will match all files; <code>c*</code> will
14493 #                         match all files beginning with
14494 #                         <code>c</code>; <code>*c</code> will match
14495 #                         all files ending with <code>c</code>; and
14496 #                         <code>\*c\*</code> will match all files that
14497 #                         have <code>c</code> in them (including at
14498 #                         the beginning or end). Equivalent to
14499 #                         <code>/ .* /x</code> in regexp. Note, this
14500 #                         will not match Unix-like hidden files (dotfiles).
14501 #                         In order to include those in the match results,
14502 #                         you must use something like <code>"{*,.*}"</code>.
14503 # <code>**</code>::       Matches directories recursively.
14504 # <code>?</code>::        Matches any one character. Equivalent to
14505 #                         <code>/.{1}/</code> in regexp.
14506 # <code>[set]</code>::    Matches any one character in +set+.
14507 #                         Behaves exactly like character sets in
14508 #                         Regexp, including set negation
14509 #                         (<code>[^a-z]</code>).
14510 # <code>{p,q}</code>::    Matches either literal <code>p</code> or
14511 #                         literal <code>q</code>. Matching literals
14512 #                         may be more than one character in length.
14513 #                         More than two literals may be specified.
14514 #                         Equivalent to pattern alternation in
14515 #                         regexp.
14516 # <code> \\ </code>::     Escapes the next metacharacter.
14517 #                         Note that this means you cannot use backslash
14518 #                         in windows as part of a glob,
14519 #                         i.e. <code>Dir["c:\\foo*"]</code> will not work,
14520 #                         use <code>Dir["c:/foo*"]</code> instead.
14521 # 
14522 #    Dir["config.?"]                     #=> ["config.h"]
14523 #    Dir.glob("config.?")                #=> ["config.h"]
14524 #    Dir.glob("*.[a-z][a-z]")            #=> ["main.rb"]
14525 #    Dir.glob("*.[^r]*")                 #=> ["config.h"]
14526 #    Dir.glob("*.{rb,h}")                #=> ["main.rb", "config.h"]
14527 #    Dir.glob("*")                       #=> ["config.h", "main.rb"]
14528 #    Dir.glob("*", File::FNM_DOTMATCH)   #=> [".", "..", "config.h", "main.rb"]
14529 # 
14530 #    rbfiles = File.join("**", "*.rb")
14531 #    Dir.glob(rbfiles)                   #=> ["main.rb",
14532 #                                        #    "lib/song.rb",
14533 #                                        #    "lib/song/karaoke.rb"]
14534 #    libdirs = File.join("**", "lib")
14535 #    Dir.glob(libdirs)                   #=> ["lib"]
14536 # 
14537 #    librbfiles = File.join("**", "lib", "**", "*.rb")
14538 #    Dir.glob(librbfiles)                #=> ["lib/song.rb",
14539 #                                        #    "lib/song/karaoke.rb"]
14540 # 
14541 #    librbfiles = File.join("**", "lib", "*.rb")
14542 #    Dir.glob(librbfiles)                #=> ["lib/song.rb"]
14543 def self.glob( pattern, flags=0); end
14544 ##
14545 # Equivalent to calling
14546 # <code>Dir.glob(</code><i>array,</i><code>0)</code> and
14547 # <code>Dir.glob([</code><i>string,...</i><code>],0)</code>.
14548 def self.[]; []; end
14549 ##
14550 # Returns <code>true</code> if the named file is a directory,
14551 # <code>false</code> otherwise.
14552 def self.exist?(file_name); true || false; end
14553 ##
14554 # Returns <code>true</code> if the named file is a directory,
14555 # <code>false</code> otherwise.
14556 def self.exists?(file_name); true || false; end
14557 end
14558 
14559 class File < Object
14560 ##
14561 # Objects of class <code>File::Stat</code> encapsulate common status
14562 # information for <code>File</code> objects. The information is
14563 # recorded at the moment the <code>File::Stat</code> object is
14564 # created; changes made to the file after that point will not be
14565 # reflected. <code>File::Stat</code> objects are returned by
14566 # <code>IO#stat</code>, <code>File::stat</code>,
14567 # <code>File#lstat</code>, and <code>File::lstat</code>. Many of these
14568 # methods return platform-specific values, and not all values are
14569 # meaningful on all systems. See also <code>Kernel#test</code>.
14570 class Stat < Object
14571 include Comparable
14572 ##
14573 # Create a File::Stat object for the given file name (raising an
14574 # exception if the file doesn't exist).
14575 def self.new(file_name); end
14576 ##
14577 # Compares File::Stat objects by comparing their respective modification
14578 # times.
14579 # 
14580 # +nil+ is returned if the two values are incomparable.
14581 # 
14582 #    f1 = File.new("f1", "w")
14583 #    sleep 1
14584 #    f2 = File.new("f2", "w")
14585 #    f1.stat <=> f2.stat   #=> -1
14586 def <=>; 1 || nil; end
14587 ##
14588 # Returns an integer representing the device on which <i>stat</i>
14589 # resides.
14590 # 
14591 #    File.stat("testfile").dev   #=> 774
14592 def dev; 0; end
14593 ##
14594 # Returns the major part of <code>File_Stat#dev</code> or
14595 # <code>nil</code>.
14596 # 
14597 #    File.stat("/dev/fd1").dev_major   #=> 2
14598 #    File.stat("/dev/tty").dev_major   #=> 5
14599 def dev_major; 0; end
14600 ##
14601 # Returns the minor part of <code>File_Stat#dev</code> or
14602 # <code>nil</code>.
14603 # 
14604 #    File.stat("/dev/fd1").dev_minor   #=> 1
14605 #    File.stat("/dev/tty").dev_minor   #=> 0
14606 def dev_minor; 0; end
14607 ##
14608 # Returns the inode number for <i>stat</i>.
14609 # 
14610 #    File.stat("testfile").ino   #=> 1083669
14611 def ino; 0; end
14612 ##
14613 # Returns an integer representing the permission bits of
14614 # <i>stat</i>. The meaning of the bits is platform dependent; on
14615 # Unix systems, see <code>stat(2)</code>.
14616 # 
14617 #    File.chmod(0644, "testfile")   #=> 1
14618 #    s = File.stat("testfile")
14619 #    sprintf("%o", s.mode)          #=> "100644"
14620 def mode; 0; end
14621 ##
14622 # Returns the number of hard links to <i>stat</i>.
14623 # 
14624 #    File.stat("testfile").nlink             #=> 1
14625 #    File.link("testfile", "testfile.bak")   #=> 0
14626 #    File.stat("testfile").nlink             #=> 2
14627 def nlink; 0; end
14628 ##
14629 # Returns the numeric user id of the owner of <i>stat</i>.
14630 # 
14631 #    File.stat("testfile").uid   #=> 501
14632 def uid; 0; end
14633 ##
14634 # Returns the numeric group id of the owner of <i>stat</i>.
14635 # 
14636 #    File.stat("testfile").gid   #=> 500
14637 def gid; 0; end
14638 ##
14639 # Returns an integer representing the device type on which
14640 # <i>stat</i> resides. Returns <code>nil</code> if the operating
14641 # system doesn't support this feature.
14642 # 
14643 #    File.stat("/dev/fd1").rdev   #=> 513
14644 #    File.stat("/dev/tty").rdev   #=> 1280
14645 def rdev; 1 || nil; end
14646 ##
14647 # Returns the major part of <code>File_Stat#rdev</code> or
14648 # <code>nil</code>.
14649 # 
14650 #    File.stat("/dev/fd1").rdev_major   #=> 2
14651 #    File.stat("/dev/tty").rdev_major   #=> 5
14652 def rdev_major; 0; end
14653 ##
14654 # Returns the minor part of <code>File_Stat#rdev</code> or
14655 # <code>nil</code>.
14656 # 
14657 #    File.stat("/dev/fd1").rdev_minor   #=> 1
14658 #    File.stat("/dev/tty").rdev_minor   #=> 0
14659 def rdev_minor; 0; end
14660 ##
14661 # Returns the size of <i>stat</i> in bytes.
14662 # 
14663 #    File.stat("testfile").size   #=> 66
14664 def size; 0; end
14665 ##
14666 # Returns the native file system's block size. Will return <code>nil</code>
14667 # on platforms that don't support this information.
14668 # 
14669 #    File.stat("testfile").blksize   #=> 4096
14670 def blksize; 1 || nil; end
14671 ##
14672 # Returns the number of native file system blocks allocated for this
14673 # file, or <code>nil</code> if the operating system doesn't
14674 # support this feature.
14675 # 
14676 #    File.stat("testfile").blocks   #=> 2
14677 def blocks; 1 || nil; end
14678 ##
14679 # Returns the last access time for this file as an object of class
14680 # <code>Time</code>.
14681 # 
14682 #    File.stat("testfile").atime   #=> Wed Dec 31 18:00:00 CST 1969
14683 def atime; Time.new; end
14684 ##
14685 # Returns the modification time of <i>stat</i>.
14686 # 
14687 #    File.stat("testfile").mtime   #=> Wed Apr 09 08:53:14 CDT 2003
14688 def mtime; Time.new; end
14689 ##
14690 # Returns the change time for <i>stat</i> (that is, the time
14691 # directory information about the file was changed, not the file
14692 # itself).
14693 # 
14694 # Note that on Windows (NTFS), returns creation time (birth time).
14695 # 
14696 #    File.stat("testfile").ctime   #=> Wed Apr 09 08:53:14 CDT 2003
14697 def ctime; Time.new; end
14698 ##
14699 # Produce a nicely formatted description of <i>stat</i>.
14700 # 
14701 #   File.stat("/etc/passwd").inspect
14702 #      #=> "#<File::Stat dev=0xe000005, ino=1078078, mode=0100644,
14703 #      #    nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096,
14704 #      #    blocks=8, atime=Wed Dec 10 10:16:12 CST 2003,
14705 #      #    mtime=Fri Sep 12 15:41:41 CDT 2003,
14706 #      #    ctime=Mon Oct 27 11:20:27 CST 2003>"
14707 def inspect; ''; end
14708 ##
14709 # Identifies the type of <i>stat</i>. The return string is one of:
14710 # ``<code>file</code>'', ``<code>directory</code>'',
14711 # ``<code>characterSpecial</code>'', ``<code>blockSpecial</code>'',
14712 # ``<code>fifo</code>'', ``<code>link</code>'',
14713 # ``<code>socket</code>'', or ``<code>unknown</code>''.
14714 # 
14715 #    File.stat("/dev/tty").ftype   #=> "characterSpecial"
14716 def ftype; ''; end
14717 ##
14718 # Returns <code>true</code> if the named file is a directory,
14719 # or a symlink that points at a directory, and <code>false</code>
14720 # otherwise.
14721 # 
14722 #    File.directory?(".")
14723 def directory?(file_name); true || false; end
14724 ##
14725 # Returns <code>true</code> if <i>stat</i> is readable by the
14726 # effective user id of this process.
14727 # 
14728 #    File.stat("testfile").readable?   #=> true
14729 def readable?; true || false; end
14730 ##
14731 # Returns <code>true</code> if <i>stat</i> is readable by the real
14732 # user id of this process.
14733 # 
14734 #    File.stat("testfile").readable_real?   #=> true
14735 def readable_real?; true || false; end
14736 ##
14737 # If <i>stat</i> is readable by others, returns an integer
14738 # representing the file permission bits of <i>stat</i>. Returns
14739 # <code>nil</code> otherwise. The meaning of the bits is platform
14740 # dependent; on Unix systems, see <code>stat(2)</code>.
14741 # 
14742 #    m = File.stat("/etc/passwd").world_readable?  #=> 420
14743 #    sprintf("%o", m)                              #=> "644"
14744 def world_readable?; 1 || nil; end
14745 ##
14746 # Returns <code>true</code> if <i>stat</i> is writable by the
14747 # effective user id of this process.
14748 # 
14749 #    File.stat("testfile").writable?   #=> true
14750 def writable?; true || false; end
14751 ##
14752 # Returns <code>true</code> if <i>stat</i> is writable by the real
14753 # user id of this process.
14754 # 
14755 #    File.stat("testfile").writable_real?   #=> true
14756 def writable_real?; true || false; end
14757 ##
14758 # If <i>stat</i> is writable by others, returns an integer
14759 # representing the file permission bits of <i>stat</i>. Returns
14760 # <code>nil</code> otherwise. The meaning of the bits is platform
14761 # dependent; on Unix systems, see <code>stat(2)</code>.
14762 # 
14763 #    m = File.stat("/tmp").world_writable?         #=> 511
14764 #    sprintf("%o", m)                              #=> "777"
14765 def world_writable?; 1 || nil; end
14766 ##
14767 # Returns <code>true</code> if <i>stat</i> is executable or if the
14768 # operating system doesn't distinguish executable files from
14769 # nonexecutable files. The tests are made using the effective owner of
14770 # the process.
14771 # 
14772 #    File.stat("testfile").executable?   #=> false
14773 def executable?; true || false; end
14774 ##
14775 # Same as <code>executable?</code>, but tests using the real owner of
14776 # the process.
14777 def executable_real?; true || false; end
14778 ##
14779 # Returns <code>true</code> if <i>stat</i> is a regular file (not
14780 # a device file, pipe, socket, etc.).
14781 # 
14782 #    File.stat("testfile").file?   #=> true
14783 def file?; true || false; end
14784 ##
14785 # Returns <code>true</code> if <i>stat</i> is a zero-length file;
14786 # <code>false</code> otherwise.
14787 # 
14788 #    File.stat("testfile").zero?   #=> false
14789 def zero?; true || false; end
14790 ##
14791 # Returns <code>true</code> if the effective user id of the process is
14792 # the same as the owner of <i>stat</i>.
14793 # 
14794 #    File.stat("testfile").owned?      #=> true
14795 #    File.stat("/etc/passwd").owned?   #=> false
14796 def owned?; true || false; end
14797 ##
14798 # Returns true if the effective group id of the process is the same as
14799 # the group id of <i>stat</i>. On Windows NT, returns <code>false</code>.
14800 # 
14801 #    File.stat("testfile").grpowned?      #=> true
14802 #    File.stat("/etc/passwd").grpowned?   #=> false
14803 def grpowned?; true || false; end
14804 ##
14805 # Returns <code>true</code> if the operating system supports pipes and
14806 # <i>stat</i> is a pipe; <code>false</code> otherwise.
14807 def pipe?; true || false; end
14808 ##
14809 # Returns <code>true</code> if <i>stat</i> is a symbolic link,
14810 # <code>false</code> if it isn't or if the operating system doesn't
14811 # support this feature. As <code>File::stat</code> automatically
14812 # follows symbolic links, <code>symlink?</code> will always be
14813 # <code>false</code> for an object returned by
14814 # <code>File::stat</code>.
14815 # 
14816 #    File.symlink("testfile", "alink")   #=> 0
14817 #    File.stat("alink").symlink?         #=> false
14818 #    File.lstat("alink").symlink?        #=> true
14819 def symlink?; true || false; end
14820 ##
14821 # Returns <code>true</code> if <i>stat</i> is a socket,
14822 # <code>false</code> if it isn't or if the operating system doesn't
14823 # support this feature.
14824 # 
14825 #    File.stat("testfile").socket?   #=> false
14826 def socket?; true || false; end
14827 ##
14828 # Returns <code>true</code> if the file is a block device,
14829 # <code>false</code> if it isn't or if the operating system doesn't
14830 # support this feature.
14831 # 
14832 #    File.stat("testfile").blockdev?    #=> false
14833 #    File.stat("/dev/hda1").blockdev?   #=> true
14834 def blockdev?; true || false; end
14835 ##
14836 # Returns <code>true</code> if the file is a character device,
14837 # <code>false</code> if it isn't or if the operating system doesn't
14838 # support this feature.
14839 # 
14840 #    File.stat("/dev/tty").chardev?   #=> true
14841 def chardev?; true || false; end
14842 ##
14843 # Returns <code>true</code> if <i>stat</i> has the set-user-id
14844 # permission bit set, <code>false</code> if it doesn't or if the
14845 # operating system doesn't support this feature.
14846 # 
14847 #    File.stat("/bin/su").setuid?   #=> true
14848 def setuid?; true || false; end
14849 ##
14850 # Returns <code>true</code> if <i>stat</i> has the set-group-id
14851 # permission bit set, <code>false</code> if it doesn't or if the
14852 # operating system doesn't support this feature.
14853 # 
14854 #    File.stat("/usr/sbin/lpc").setgid?   #=> true
14855 def setgid?; true || false; end
14856 ##
14857 # Returns <code>true</code> if <i>stat</i> has its sticky bit set,
14858 # <code>false</code> if it doesn't or if the operating system doesn't
14859 # support this feature.
14860 # 
14861 #    File.stat("testfile").sticky?   #=> false
14862 def sticky?; true || false; end
14863 end
14864 
14865 ##
14866 # Returns true if <i>path</i> matches against <i>pattern</i> The
14867 # pattern is not a regular expression; instead it follows rules
14868 # similar to shell filename globbing. It may contain the following
14869 # metacharacters:
14870 # 
14871 # <code>*</code>::        Matches any file. Can be restricted by
14872 #                         other values in the glob. <code>*</code>
14873 #                         will match all files; <code>c*</code> will
14874 #                         match all files beginning with
14875 #                         <code>c</code>; <code>*c</code> will match
14876 #                         all files ending with <code>c</code>; and
14877 #                         <code>\*c*</code> will match all files that
14878 #                         have <code>c</code> in them (including at
14879 #                         the beginning or end). Equivalent to
14880 #                         <code>/ .* /x</code> in regexp.
14881 # <code>**</code>::       Matches directories recursively or files
14882 #                         expansively.
14883 # <code>?</code>::        Matches any one character. Equivalent to
14884 #                         <code>/.{1}/</code> in regexp.
14885 # <code>[set]</code>::    Matches any one character in +set+.
14886 #                         Behaves exactly like character sets in
14887 #                         Regexp, including set negation
14888 #                         (<code>[^a-z]</code>).
14889 # <code> \ </code>::      Escapes the next metacharacter.
14890 # 
14891 # <i>flags</i> is a bitwise OR of the <code>FNM_xxx</code>
14892 # parameters. The same glob pattern and flags are used by
14893 # <code>Dir::glob</code>.
14894 # 
14895 #    File.fnmatch('cat',       'cat')        #=> true  # match entire string
14896 #    File.fnmatch('cat',       'category')   #=> false # only match partial string
14897 #    File.fnmatch('c{at,ub}s', 'cats')       #=> false # { } isn't supported
14898 # 
14899 #    File.fnmatch('c?t',     'cat')          #=> true  # '?' match only 1 character
14900 #    File.fnmatch('c??t',    'cat')          #=> false # ditto
14901 #    File.fnmatch('c*',      'cats')         #=> true  # '*' match 0 or more characters
14902 #    File.fnmatch('c*t',     'c/a/b/t')      #=> true  # ditto
14903 #    File.fnmatch('ca[a-z]', 'cat')          #=> true  # inclusive bracket expression
14904 #    File.fnmatch('ca[^t]',  'cat')          #=> false # exclusive bracket expression ('^' or '!')
14905 # 
14906 #    File.fnmatch('cat', 'CAT')                     #=> false # case sensitive
14907 #    File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true  # case insensitive
14908 # 
14909 #    File.fnmatch('?',   '/', File::FNM_PATHNAME)  #=> false # wildcard doesn't match '/' on FNM_PATHNAME
14910 #    File.fnmatch('*',   '/', File::FNM_PATHNAME)  #=> false # ditto
14911 #    File.fnmatch('[/]', '/', File::FNM_PATHNAME)  #=> false # ditto
14912 # 
14913 #    File.fnmatch('\?',   '?')                       #=> true  # escaped wildcard becomes ordinary
14914 #    File.fnmatch('\a',   'a')                       #=> true  # escaped ordinary remains ordinary
14915 #    File.fnmatch('\a',   '\a', File::FNM_NOESCAPE)  #=> true  # FNM_NOESACPE makes '\' ordinary
14916 #    File.fnmatch('[\?]', '?')                       #=> true  # can escape inside bracket expression
14917 # 
14918 #    File.fnmatch('*',   '.profile')                      #=> false # wildcard doesn't match leading
14919 #    File.fnmatch('*',   '.profile', File::FNM_DOTMATCH)  #=> true  # period by default.
14920 #    File.fnmatch('.*',  '.profile')                      #=> true
14921 # 
14922 #    rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
14923 #    File.fnmatch(rbfiles, 'main.rb')                    #=> false
14924 #    File.fnmatch(rbfiles, './main.rb')                  #=> false
14925 #    File.fnmatch(rbfiles, 'lib/song.rb')                #=> true
14926 #    File.fnmatch('**.rb', 'main.rb')                    #=> true
14927 #    File.fnmatch('**.rb', './main.rb')                  #=> false
14928 #    File.fnmatch('**.rb', 'lib/song.rb')                #=> true
14929 #    File.fnmatch('*',           'dave/.profile')                      #=> true
14930 # 
14931 #    pattern = '*' '/' '*'
14932 #    File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME)  #=> false
14933 #    File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
14934 # 
14935 #    pattern = '**' '/' 'foo'
14936 #    File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME)     #=> true
14937 #    File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME)    #=> true
14938 #    File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME)  #=> true
14939 #    File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME)    #=> false
14940 #    File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
14941 def self.fnmatch( pattern, path, flags=0); true || false; end
14942 ##
14943 # Returns true if <i>path</i> matches against <i>pattern</i> The
14944 # pattern is not a regular expression; instead it follows rules
14945 # similar to shell filename globbing. It may contain the following
14946 # metacharacters:
14947 # 
14948 # <code>*</code>::        Matches any file. Can be restricted by
14949 #                         other values in the glob. <code>*</code>
14950 #                         will match all files; <code>c*</code> will
14951 #                         match all files beginning with
14952 #                         <code>c</code>; <code>*c</code> will match
14953 #                         all files ending with <code>c</code>; and
14954 #                         <code>\*c*</code> will match all files that
14955 #                         have <code>c</code> in them (including at
14956 #                         the beginning or end). Equivalent to
14957 #                         <code>/ .* /x</code> in regexp.
14958 # <code>**</code>::       Matches directories recursively or files
14959 #                         expansively.
14960 # <code>?</code>::        Matches any one character. Equivalent to
14961 #                         <code>/.{1}/</code> in regexp.
14962 # <code>[set]</code>::    Matches any one character in +set+.
14963 #                         Behaves exactly like character sets in
14964 #                         Regexp, including set negation
14965 #                         (<code>[^a-z]</code>).
14966 # <code> \ </code>::      Escapes the next metacharacter.
14967 # 
14968 # <i>flags</i> is a bitwise OR of the <code>FNM_xxx</code>
14969 # parameters. The same glob pattern and flags are used by
14970 # <code>Dir::glob</code>.
14971 # 
14972 #    File.fnmatch('cat',       'cat')        #=> true  # match entire string
14973 #    File.fnmatch('cat',       'category')   #=> false # only match partial string
14974 #    File.fnmatch('c{at,ub}s', 'cats')       #=> false # { } isn't supported
14975 # 
14976 #    File.fnmatch('c?t',     'cat')          #=> true  # '?' match only 1 character
14977 #    File.fnmatch('c??t',    'cat')          #=> false # ditto
14978 #    File.fnmatch('c*',      'cats')         #=> true  # '*' match 0 or more characters
14979 #    File.fnmatch('c*t',     'c/a/b/t')      #=> true  # ditto
14980 #    File.fnmatch('ca[a-z]', 'cat')          #=> true  # inclusive bracket expression
14981 #    File.fnmatch('ca[^t]',  'cat')          #=> false # exclusive bracket expression ('^' or '!')
14982 # 
14983 #    File.fnmatch('cat', 'CAT')                     #=> false # case sensitive
14984 #    File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true  # case insensitive
14985 # 
14986 #    File.fnmatch('?',   '/', File::FNM_PATHNAME)  #=> false # wildcard doesn't match '/' on FNM_PATHNAME
14987 #    File.fnmatch('*',   '/', File::FNM_PATHNAME)  #=> false # ditto
14988 #    File.fnmatch('[/]', '/', File::FNM_PATHNAME)  #=> false # ditto
14989 # 
14990 #    File.fnmatch('\?',   '?')                       #=> true  # escaped wildcard becomes ordinary
14991 #    File.fnmatch('\a',   'a')                       #=> true  # escaped ordinary remains ordinary
14992 #    File.fnmatch('\a',   '\a', File::FNM_NOESCAPE)  #=> true  # FNM_NOESACPE makes '\' ordinary
14993 #    File.fnmatch('[\?]', '?')                       #=> true  # can escape inside bracket expression
14994 # 
14995 #    File.fnmatch('*',   '.profile')                      #=> false # wildcard doesn't match leading
14996 #    File.fnmatch('*',   '.profile', File::FNM_DOTMATCH)  #=> true  # period by default.
14997 #    File.fnmatch('.*',  '.profile')                      #=> true
14998 # 
14999 #    rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
15000 #    File.fnmatch(rbfiles, 'main.rb')                    #=> false
15001 #    File.fnmatch(rbfiles, './main.rb')                  #=> false
15002 #    File.fnmatch(rbfiles, 'lib/song.rb')                #=> true
15003 #    File.fnmatch('**.rb', 'main.rb')                    #=> true
15004 #    File.fnmatch('**.rb', './main.rb')                  #=> false
15005 #    File.fnmatch('**.rb', 'lib/song.rb')                #=> true
15006 #    File.fnmatch('*',           'dave/.profile')                      #=> true
15007 # 
15008 #    pattern = '*' '/' '*'
15009 #    File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME)  #=> false
15010 #    File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
15011 # 
15012 #    pattern = '**' '/' 'foo'
15013 #    File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME)     #=> true
15014 #    File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME)    #=> true
15015 #    File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME)  #=> true
15016 #    File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME)    #=> false
15017 #    File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
15018 def self.fnmatch?( pattern, path, flags=0); true || false; end
15019 ##
15020 # Returns a <code>File::Stat</code> object for the named file (see
15021 # <code>File::Stat</code>).
15022 # 
15023 #    File.stat("testfile").mtime   #=> Tue Apr 08 12:58:04 CDT 2003
15024 def self.stat(file_name); ''; end
15025 ##
15026 # Same as <code>File::stat</code>, but does not follow the last symbolic
15027 # link. Instead, reports on the link itself.
15028 # 
15029 #    File.symlink("testfile", "link2test")   #=> 0
15030 #    File.stat("testfile").size              #=> 66
15031 #    File.lstat("link2test").size            #=> 8
15032 #    File.stat("link2test").size             #=> 66
15033 def self.lstat(file_name); ''; end
15034 ##
15035 # Identifies the type of the named file; the return string is one of
15036 # ``<code>file</code>'', ``<code>directory</code>'',
15037 # ``<code>characterSpecial</code>'', ``<code>blockSpecial</code>'',
15038 # ``<code>fifo</code>'', ``<code>link</code>'',
15039 # ``<code>socket</code>'', or ``<code>unknown</code>''.
15040 # 
15041 #    File.ftype("testfile")            #=> "file"
15042 #    File.ftype("/dev/tty")            #=> "characterSpecial"
15043 #    File.ftype("/tmp/.X11-unix/X0")   #=> "socket"
15044 def self.ftype(file_name); ''; end
15045 ##
15046 # Returns the last access time for the named file as a Time object).
15047 # 
15048 #    File.atime("testfile")   #=> Wed Apr 09 08:51:48 CDT 2003
15049 def self.atime(file_name); Time.new; end
15050 ##
15051 # Returns the modification time for the named file as a Time object.
15052 # 
15053 #    File.mtime("testfile")   #=> Tue Apr 08 12:58:04 CDT 2003
15054 def self.mtime(file_name); Time.new; end
15055 ##
15056 # Returns the change time for the named file (the time at which
15057 # directory information about the file was changed, not the file
15058 # itself).
15059 # 
15060 # Note that on Windows (NTFS), returns creation time (birth time).
15061 # 
15062 #    File.ctime("testfile")   #=> Wed Apr 09 08:53:13 CDT 2003
15063 def self.ctime(file_name); Time.new; end
15064 ##
15065 # Sets the access and modification times of each
15066 # named file to the first two arguments. Returns
15067 # the number of file names in the argument list.
15068 def self.utime(); 0; end
15069 ##
15070 # Changes permission bits on the named file(s) to the bit pattern
15071 # represented by <i>mode_int</i>. Actual effects are operating system
15072 # dependent (see the beginning of this section). On Unix systems, see
15073 # <code>chmod(2)</code> for details. Returns the number of files
15074 # processed.
15075 # 
15076 #    File.chmod(0644, "testfile", "out")   #=> 2
15077 def self.chmod(); 0; end
15078 ##
15079 # Changes the owner and group of the named file(s) to the given
15080 # numeric owner and group id's. Only a process with superuser
15081 # privileges may change the owner of a file. The current owner of a
15082 # file may change the file's group to any group to which the owner
15083 # belongs. A <code>nil</code> or -1 owner or group id is ignored.
15084 # Returns the number of files processed.
15085 # 
15086 #    File.chown(nil, 100, "testfile")
15087 def self.chown(owner_int, group_int ); 0; end
15088 ##
15089 # Equivalent to <code>File::chmod</code>, but does not follow symbolic
15090 # links (so it will change the permissions associated with the link,
15091 # not the file referenced by the link). Often not available.
15092 def self.lchmod(); 0; end
15093 ##
15094 # Equivalent to <code>File::chown</code>, but does not follow symbolic
15095 # links (so it will change the owner associated with the link, not the
15096 # file referenced by the link). Often not available. Returns number
15097 # of files in the argument list.
15098 def self.lchown(); 0; end
15099 ##
15100 # Creates a new name for an existing file using a hard link. Will not
15101 # overwrite <i>new_name</i> if it already exists (raising a subclass
15102 # of <code>SystemCallError</code>). Not available on all platforms.
15103 # 
15104 #    File.link("testfile", ".testfile")   #=> 0
15105 #    IO.readlines(".testfile")[0]         #=> "This is line one\n"
15106 def self.link(old_name, new_name); 0; end
15107 ##
15108 # Creates a symbolic link called <i>new_name</i> for the existing file
15109 # <i>old_name</i>. Raises a <code>NotImplemented</code> exception on
15110 # platforms that do not support symbolic links.
15111 # 
15112 #    File.symlink("testfile", "link2test")   #=> 0
15113 def self.symlink(old_name, new_name); 0; end
15114 ##
15115 # Returns the name of the file referenced by the given link.
15116 # Not available on all platforms.
15117 # 
15118 #    File.symlink("testfile", "link2test")   #=> 0
15119 #    File.readlink("link2test")              #=> "testfile"
15120 def self.readlink(link_name); ''; end
15121 ##
15122 # Deletes the named files, returning the number of names
15123 # passed as arguments. Raises an exception on any error.
15124 # See also <code>Dir::rmdir</code>.
15125 def self.delete(); 0; end
15126 ##
15127 # Deletes the named files, returning the number of names
15128 # passed as arguments. Raises an exception on any error.
15129 # See also <code>Dir::rmdir</code>.
15130 def self.unlink(); 0; end
15131 ##
15132 # Renames the given file to the new name. Raises a
15133 # <code>SystemCallError</code> if the file cannot be renamed.
15134 # 
15135 #    File.rename("afile", "afile.bak")   #=> 0
15136 def self.rename(old_name, new_name); 0; end
15137 ##
15138 # Returns the current umask value for this process. If the optional
15139 # argument is given, set the umask to that value and return the
15140 # previous value. Umask values are <em>subtracted</em> from the
15141 # default permissions, so a umask of <code>0222</code> would make a
15142 # file read-only for everyone.
15143 # 
15144 #    File.umask(0006)   #=> 18
15145 #    File.umask         #=> 6
15146 def self.umask(); 0; end
15147 ##
15148 # Truncates the file <i>file_name</i> to be at most <i>integer</i>
15149 # bytes long. Not available on all platforms.
15150 # 
15151 #    f = File.new("out", "w")
15152 #    f.write("1234567890")     #=> 10
15153 #    f.close                   #=> nil
15154 #    File.truncate("out", 5)   #=> 0
15155 #    File.size("out")          #=> 5
15156 def self.truncate(file_name, integer); 0; end
15157 ##
15158 # Converts a pathname to an absolute pathname. Relative paths are
15159 # referenced from the current working directory of the process unless
15160 # <i>dir_string</i> is given, in which case it will be used as the
15161 # starting point. The given pathname may start with a
15162 # ``<code>~</code>'', which expands to the process owner's home
15163 # directory (the environment variable <code>HOME</code> must be set
15164 # correctly). ``<code>~</code><i>user</i>'' expands to the named
15165 # user's home directory.
15166 # 
15167 #    File.expand_path("~oracle/bin")           #=> "/home/oracle/bin"
15168 #    File.expand_path("../../bin", "/tmp/x")   #=> "/bin"
15169 def self.expand_path(file_name  , dir_string=0); ''; end
15170 ##
15171 # Converts a pathname to an absolute pathname. Relative paths are
15172 # referenced from the current working directory of the process unless
15173 # <i>dir_string</i> is given, in which case it will be used as the
15174 # starting point. If the given pathname starts with a ``<code>~</code>''
15175 # it is NOT expanded, it is treated as a normal directory name.
15176 # 
15177 #    File.absolute_path("~oracle/bin")       #=> "<relative_path>/~oracle/bin"
15178 def self.absolute_path(file_name  , dir_string=0); ''; end
15179 ##
15180 # Returns the real (absolute) pathname of _pathname_ in the actual
15181 # filesystem not containing symlinks or useless dots.
15182 # 
15183 # If _dir_string_ is given, it is used as a base directory
15184 # for interpreting relative pathname instead of the current directory.
15185 # 
15186 # All components of the pathname must exist when this method is
15187 # called.
15188 def self.realpath(pathname , dir_string=0); ''; end
15189 ##
15190 # Returns the real (absolute) pathname of _pathname_ in the actual filesystem.
15191 # The real pathname doesn't contain symlinks or useless dots.
15192 # 
15193 # If _dir_string_ is given, it is used as a base directory
15194 # for interpreting relative pathname instead of the current directory.
15195 # 
15196 # The last component of the real pathname can be nonexistent.
15197 def self.realdirpath(pathname , dir_string=0); ''; end
15198 ##
15199 # Returns the last component of the filename given in <i>file_name</i>,
15200 # which can be formed using both <code>File::SEPARATOR</code> and
15201 # <code>File::ALT_SEPARETOR</code> as the separator when
15202 # <code>File::ALT_SEPARATOR</code> is not <code>nil</code>. If
15203 # <i>suffix</i> is given and present at the end of <i>file_name</i>,
15204 # it is removed.
15205 # 
15206 #    File.basename("/home/gumby/work/ruby.rb")          #=> "ruby.rb"
15207 #    File.basename("/home/gumby/work/ruby.rb", ".rb")   #=> "ruby"
15208 def self.basename(file_name  , suffix=0); ''; end
15209 ##
15210 # Returns all components of the filename given in <i>file_name</i>
15211 # except the last one. The filename can be formed using both
15212 # <code>File::SEPARATOR</code> and <code>File::ALT_SEPARETOR</code> as the
15213 # separator when <code>File::ALT_SEPARATOR</code> is not <code>nil</code>.
15214 # 
15215 #    File.dirname("/home/gumby/work/ruby.rb")   #=> "/home/gumby/work"
15216 def self.dirname(file_name ); ''; end
15217 ##
15218 # Returns the extension (the portion of file name in +path+
15219 # starting from the last period).
15220 # 
15221 # If +path+ is a dotfile, or starts with a period, then the starting
15222 # dot is not dealt with the start of the extension.
15223 # 
15224 # An empty string will also be returned when the period is the last character
15225 # in +path+.
15226 # 
15227 #    File.extname("test.rb")         #=> ".rb"
15228 #    File.extname("a/b/d/test.rb")   #=> ".rb"
15229 #    File.extname("foo.")            #=> ""
15230 #    File.extname("test")            #=> ""
15231 #    File.extname(".profile")        #=> ""
15232 #    File.extname(".profile.sh")     #=> ".sh"
15233 def self.extname(path); ''; end
15234 ##
15235 # Returns the string representation of the path
15236 # 
15237 #    File.path("/dev/null")          #=> "/dev/null"
15238 #    File.path(Pathname.new("/tmp")) #=> "/tmp"
15239 def self.path(path); ''; end
15240 ##
15241 # Splits the given string into a directory and a file component and
15242 # returns them in a two-element array. See also
15243 # <code>File::dirname</code> and <code>File::basename</code>.
15244 # 
15245 #    File.split("/home/gumby/.profile")   #=> ["/home/gumby", ".profile"]
15246 def self.split(file_name); []; end
15247 ##
15248 # Returns a new string formed by joining the strings using
15249 # <code>File::SEPARATOR</code>.
15250 # 
15251 #    File.join("usr", "mail", "gumby")   #=> "usr/mail/gumby"
15252 def self.join(); ''; end
15253 ##
15254 # Returns the size of <i>file</i> in bytes.
15255 # 
15256 #    File.new("testfile").size   #=> 66
15257 def size(file_name); 0; end
15258 ##
15259 # Locks or unlocks a file according to <i>locking_constant</i> (a
15260 # logical <em>or</em> of the values in the table below).
15261 # Returns <code>false</code> if <code>File::LOCK_NB</code> is
15262 # specified and the operation would otherwise have blocked. Not
15263 # available on all platforms.
15264 # 
15265 # Locking constants (in class File):
15266 # 
15267 #    LOCK_EX   | Exclusive lock. Only one process may hold an
15268 #              | exclusive lock for a given file at a time.
15269 #    ----------+------------------------------------------------
15270 #    LOCK_NB   | Don't block when locking. May be combined
15271 #              | with other lock options using logical or.
15272 #    ----------+------------------------------------------------
15273 #    LOCK_SH   | Shared lock. Multiple processes may each hold a
15274 #              | shared lock for a given file at the same time.
15275 #    ----------+------------------------------------------------
15276 #    LOCK_UN   | Unlock.
15277 # 
15278 # Example:
15279 # 
15280 #    # update a counter using write lock
15281 #    # don't use "w" because it truncates the file before lock.
15282 #    File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
15283 #      f.flock(File::LOCK_EX)
15284 #      value = f.read.to_i + 1
15285 #      f.rewind
15286 #      f.write("#{value}\n")
15287 #      f.flush
15288 #      f.truncate(f.pos)
15289 #    }
15290 # 
15291 #    # read the counter using read lock
15292 #    File.open("counter", "r") {|f|
15293 #      f.flock(File::LOCK_SH)
15294 #      p f.read
15295 #    }
15296 def flock (locking_constant ); 0 || false; end
15297 ##
15298 # Returns <code>true</code> if the named file is a directory,
15299 # or a symlink that points at a directory, and <code>false</code>
15300 # otherwise.
15301 # 
15302 #    File.directory?(".")
15303 def self.directory?(file_name); true || false; end
15304 ##
15305 # Return <code>true</code> if the named file exists.
15306 def self.exist?(file_name); true || false; end
15307 ##
15308 # Return <code>true</code> if the named file exists.
15309 def self.exists?(file_name); true || false; end
15310 ##
15311 # Returns <code>true</code> if the named file is readable by the effective
15312 # user id of this process.
15313 def self.readable?(file_name); true || false; end
15314 ##
15315 # Returns <code>true</code> if the named file is readable by the real
15316 # user id of this process.
15317 def self.readable_real?(file_name); true || false; end
15318 ##
15319 # If <i>file_name</i> is readable by others, returns an integer
15320 # representing the file permission bits of <i>file_name</i>. Returns
15321 # <code>nil</code> otherwise. The meaning of the bits is platform
15322 # dependent; on Unix systems, see <code>stat(2)</code>.
15323 # 
15324 #    File.world_readable?("/etc/passwd")           #=> 420
15325 #    m = File.world_readable?("/etc/passwd")
15326 #    sprintf("%o", m)                              #=> "644"
15327 def self.world_readable?(file_name); 1 || nil; end
15328 ##
15329 # Returns <code>true</code> if the named file is writable by the effective
15330 # user id of this process.
15331 def self.writable?(file_name); true || false; end
15332 ##
15333 # Returns <code>true</code> if the named file is writable by the real
15334 # user id of this process.
15335 def self.writable_real?(file_name); true || false; end
15336 ##
15337 # If <i>file_name</i> is writable by others, returns an integer
15338 # representing the file permission bits of <i>file_name</i>. Returns
15339 # <code>nil</code> otherwise. The meaning of the bits is platform
15340 # dependent; on Unix systems, see <code>stat(2)</code>.
15341 # 
15342 #    File.world_writable?("/tmp")                  #=> 511
15343 #    m = File.world_writable?("/tmp")
15344 #    sprintf("%o", m)                              #=> "777"
15345 def self.world_writable?(file_name); 1 || nil; end
15346 ##
15347 # Returns <code>true</code> if the named file is executable by the effective
15348 # user id of this process.
15349 def self.executable?(file_name); true || false; end
15350 ##
15351 # Returns <code>true</code> if the named file is executable by the real
15352 # user id of this process.
15353 def self.executable_real?(file_name); true || false; end
15354 ##
15355 # Returns <code>true</code> if the named file exists and is a
15356 # regular file.
15357 def self.file?(file_name); true || false; end
15358 ##
15359 # Returns <code>true</code> if the named file exists and has
15360 # a zero size.
15361 def self.zero?(file_name); true || false; end
15362 ##
15363 # Returns +nil+ if +file_name+ doesn't exist or has zero size, the size of the
15364 # file otherwise.
15365 def self.size?(file_name); 0 || nil; end
15366 ##
15367 # Returns <code>true</code> if the named file exists and the
15368 # effective used id of the calling process is the owner of
15369 # the file.
15370 def self.owned?(file_name); true || false; end
15371 ##
15372 # Returns <code>true</code> if the named file exists and the
15373 # effective group id of the calling process is the owner of
15374 # the file. Returns <code>false</code> on Windows.
15375 def self.grpowned?(file_name); true || false; end
15376 ##
15377 # Returns <code>true</code> if the named file is a pipe.
15378 def self.pipe?(file_name); true || false; end
15379 ##
15380 # Returns <code>true</code> if the named file is a symbolic link.
15381 def self.symlink?(file_name); true || false; end
15382 ##
15383 # Returns <code>true</code> if the named file is a socket.
15384 def self.socket?(file_name); true || false; end
15385 ##
15386 # Returns <code>true</code> if the named file is a block device.
15387 def self.blockdev?(file_name); true || false; end
15388 ##
15389 # Returns <code>true</code> if the named file is a character device.
15390 def self.chardev?(file_name); true || false; end
15391 ##
15392 # Returns <code>true</code> if the named file has the setuid bit set.
15393 def self.setuid?(file_name); true || false; end
15394 ##
15395 # Returns <code>true</code> if the named file has the setgid bit set.
15396 def self.setgid?(file_name); true || false; end
15397 ##
15398 # Returns <code>true</code> if the named file has the sticky bit set.
15399 def self.sticky?(file_name); true || false; end
15400 ##
15401 # Returns <code>true</code> if the named files are identical.
15402 # 
15403 #     open("a", "w") {}
15404 #     p File.identical?("a", "a")      #=> true
15405 #     p File.identical?("a", "./a")    #=> true
15406 #     File.link("a", "b")
15407 #     p File.identical?("a", "b")      #=> true
15408 #     File.symlink("a", "c")
15409 #     p File.identical?("a", "c")      #=> true
15410 #     open("d", "w") {}
15411 #     p File.identical?("a", "d")      #=> false
15412 def self.identical?(file_1, file_2); true || false; end
15413 ##
15414 # With no associated block, <code>File.open</code> is a synonym for
15415 # File.new. If the optional code block is given, it will
15416 # be passed the opened +file+ as an argument and the File object will
15417 # automatically be closed when the block terminates.  The value of the block
15418 # will be returned from <code>File.open</code>.
15419 # 
15420 # If a file is being created, its initial permissions may be set using the
15421 # +perm+ parameter.  See File.new for further discussion.
15422 # 
15423 # See IO.new for a description of the +mode+ and +opt+ parameters.
15424 def self.open(filename, mode="r" , opt=0); Object.new; end
15425 ##
15426 # Opens the file named by +filename+ according to the given +mode+ and
15427 # returns a new File object.
15428 # 
15429 # See IO.new for a description of +mode+ and +opt+.
15430 # 
15431 # If a file is being created, permission bits may be given in +perm+.  These
15432 # mode and permission bits are platform dependent; on Unix systems, see
15433 # open(2) and chmod(2) man pages for details.
15434 # 
15435 # === Examples
15436 # 
15437 #   f = File.new("testfile", "r")
15438 #   f = File.new("newfile",  "w+")
15439 #   f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
15440 def self.new(filename, mode="r" , opt=0); end
15441 end
15442 
15443 class IO < Object
15444 include Constants
15445 include Enumerable
15446 ##
15447 # Returns status information for <em>ios</em> as an object of type
15448 # <code>File::Stat</code>.
15449 # 
15450 #    f = File.new("testfile")
15451 #    s = f.stat
15452 #    "%o" % s.mode   #=> "100644"
15453 #    s.blksize       #=> 4096
15454 #    s.atime         #=> Wed Apr 09 08:53:54 CDT 2003
15455 def stat; ''; end
15456 ##
15457 # With no associated block, <code>IO.open</code> is a synonym for IO.new.  If
15458 # the optional code block is given, it will be passed +io+ as an argument,
15459 # and the IO object will automatically be closed when the block terminates.
15460 # In this instance, IO.open returns the value of the block.
15461 # 
15462 # See IO.new for a description of the +fd+, +mode+ and +opt+ parameters.
15463 def self.open(fd, mode="r" , opt=0); Object.new; end
15464 ##
15465 # Opens the given path, returning the underlying file descriptor as a
15466 # <code>Fixnum</code>.
15467 # 
15468 #    IO.sysopen("testfile")   #=> 3
15469 def self.sysopen(path, mode=0, perm=0); 0; end
15470 ##
15471 # Synonym for <code>IO.new</code>.
15472 def self.for_fd(fd, mode , opt=0); IO.new; end
15473 ##
15474 # Runs the specified command as a subprocess; the subprocess's
15475 # standard input and output will be connected to the returned
15476 # <code>IO</code> object.
15477 # 
15478 # The PID of the started process can be obtained by IO#pid method.
15479 # 
15480 # _cmd_ is a string or an array as follows.
15481 # 
15482 #   cmd:
15483 #     "-"                                      : fork
15484 #     commandline                              : command line string which is passed to a shell
15485 #     [env, cmdname, arg1, ..., opts]          : command name and zero or more arguments (no shell)
15486 #     [env, [cmdname, argv0], arg1, ..., opts] : command name, argv[0] and zero or more arguments (no shell)
15487 #   (env and opts are optional.)
15488 # 
15489 # If _cmd_ is a +String+ ``<code>-</code>'',
15490 # then a new instance of Ruby is started as the subprocess.
15491 # 
15492 # If <i>cmd</i> is an +Array+ of +String+,
15493 # then it will be used as the subprocess's +argv+ bypassing a shell.
15494 # The array can contains a hash at first for environments and
15495 # a hash at last for options similar to <code>spawn</code>.
15496 # 
15497 # The default mode for the new file object is ``r'',
15498 # but <i>mode</i> may be set to any of the modes listed in the description for class IO.
15499 # The last argument <i>opt</i> qualifies <i>mode</i>.
15500 # 
15501 #   # set IO encoding
15502 #   IO.popen("nkf -e filename", :external_encoding=>"EUC-JP") {|nkf_io|
15503 #     euc_jp_string = nkf_io.read
15504 #   }
15505 # 
15506 #   # merge standard output and standard error using
15507 #   # spawn option.  See the document of Kernel.spawn.
15508 #   IO.popen(["ls", "/", :err=>[:child, :out]]) {|ls_io|
15509 #     ls_result_with_error = ls_io.read
15510 #   }
15511 # 
15512 #   # spawn options can be mixed with IO options
15513 #   IO.popen(["ls", "/"], :err=>[:child, :out]) {|ls_io|
15514 #     ls_result_with_error = ls_io.read
15515 #   }
15516 # 
15517 # Raises exceptions which <code>IO.pipe</code> and
15518 # <code>Kernel.spawn</code> raise.
15519 # 
15520 # If a block is given, Ruby will run the command as a child connected
15521 # to Ruby with a pipe. Ruby's end of the pipe will be passed as a
15522 # parameter to the block.
15523 # At the end of block, Ruby close the pipe and sets <code>$?</code>.
15524 # In this case <code>IO.popen</code> returns
15525 # the value of the block.
15526 # 
15527 # If a block is given with a _cmd_ of ``<code>-</code>'',
15528 # the block will be run in two separate processes: once in the parent,
15529 # and once in a child. The parent process will be passed the pipe
15530 # object as a parameter to the block, the child version of the block
15531 # will be passed <code>nil</code>, and the child's standard in and
15532 # standard out will be connected to the parent through the pipe. Not
15533 # available on all platforms.
15534 # 
15535 #    f = IO.popen("uname")
15536 #    p f.readlines
15537 #    f.close
15538 #    puts "Parent is #{Process.pid}"
15539 #    IO.popen("date") { |f| puts f.gets }
15540 #    IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f.inspect}"}
15541 #    p $?
15542 #    IO.popen(%w"sed -e s|^|<foo>| -e s&$&;zot;&", "r+") {|f|
15543 #      f.puts "bar"; f.close_write; puts f.gets
15544 #    }
15545 # 
15546 # <em>produces:</em>
15547 # 
15548 #    ["Linux\n"]
15549 #    Parent is 21346
15550 #    Thu Jan 15 22:41:19 JST 2009
15551 #    21346 is here, f is #<IO:fd 3>
15552 #    21352 is here, f is nil
15553 #    #<Process::Status: pid 21352 exit 0>
15554 #    <foo>bar;zot;
15555 def self.popen(env=0, cmd=0, mode=0, r=0, opt=0); Object.new; end
15556 ##
15557 # Executes the block for every line in the named I/O port, where lines
15558 # are separated by <em>sep</em>.
15559 # 
15560 # If no block is given, an enumerator is returned instead.
15561 # 
15562 #    IO.foreach("testfile") {|x| print "GOT ", x }
15563 # 
15564 # <em>produces:</em>
15565 # 
15566 #    GOT This is line one
15567 #    GOT This is line two
15568 #    GOT This is line three
15569 #    GOT And so on...
15570 # 
15571 # If the last argument is a hash, it's the keyword argument to open.
15572 # See <code>IO.read</code> for detail.
15573 def self.foreach(name, sep=$/ , open_args=0, &block); Enumerator.new; end
15574 ##
15575 # Reads the entire file specified by <i>name</i> as individual
15576 # lines, and returns those lines in an array. Lines are separated by
15577 # <i>sep</i>.
15578 # 
15579 #    a = IO.readlines("testfile")
15580 #    a[0]   #=> "This is line one\n"
15581 # 
15582 # If the last argument is a hash, it's the keyword argument to open.
15583 # See <code>IO.read</code> for detail.
15584 def self.readlines(name, sep=$/ , open_args=0); []; end
15585 ##
15586 # Opens the file, optionally seeks to the given +offset+, then returns
15587 # +length+ bytes (defaulting to the rest of the file).  <code>read</code>
15588 # ensures the file is closed before returning.
15589 # 
15590 # If the last argument is a hash, it specifies option for internal
15591 # open().  The key would be the following.  open_args: is exclusive
15592 # to others.
15593 # 
15594 # encoding::
15595 #   string or encoding
15596 # 
15597 #   specifies encoding of the read string.  +encoding+ will be ignored
15598 #   if length is specified.
15599 # 
15600 # mode::
15601 #   string
15602 # 
15603 #   specifies mode argument for open().  It should start with "r"
15604 #   otherwise it will cause an error.
15605 # 
15606 # open_args:: array of strings
15607 # 
15608 #   specifies arguments for open() as an array.
15609 # 
15610 # Examples:
15611 # 
15612 #   IO.read("testfile")           #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
15613 #   IO.read("testfile", 20)       #=> "This is line one\nThi"
15614 #   IO.read("testfile", 20, 10)   #=> "ne one\nThis is line "
15615 def self.read(name, length=0, offset=0); '' || nil; end
15616 ##
15617 # Opens the file, optionally seeks to the given <i>offset</i>, then returns
15618 # <i>length</i> bytes (defaulting to the rest of the file).
15619 # <code>binread</code> ensures the file is closed before returning.
15620 # The open mode would be "rb:ASCII-8BIT".
15621 # 
15622 #    IO.binread("testfile")           #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
15623 #    IO.binread("testfile", 20)       #=> "This is line one\nThi"
15624 #    IO.binread("testfile", 20, 10)   #=> "ne one\nThis is line "
15625 def self.binread(name, length=0, offset=0); ''; end
15626 ##
15627 # Opens the file, optionally seeks to the given <i>offset</i>, writes
15628 # <i>string</i>, then returns the length written.
15629 # <code>write</code> ensures the file is closed before returning.
15630 # If <i>offset</i> is not given, the file is truncated.  Otherwise,
15631 # it is not truncated.
15632 # 
15633 # If the last argument is a hash, it specifies option for internal
15634 # open().  The key would be the following.  open_args: is exclusive
15635 # to others.
15636 # 
15637 #  encoding: string or encoding
15638 # 
15639 #   specifies encoding of the read string.  encoding will be ignored
15640 #   if length is specified.
15641 # 
15642 #  mode: string
15643 # 
15644 #   specifies mode argument for open().  it should start with "w" or "a" or "r+"
15645 #   otherwise it would cause error.
15646 # 
15647 #  perm: fixnum
15648 # 
15649 #   specifies perm argument for open().
15650 # 
15651 #  open_args: array
15652 # 
15653 #   specifies arguments for open() as an array.
15654 # 
15655 #    IO.write("testfile", "0123456789", 20) # => 10
15656 #    # File could contain:  "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
15657 #    IO.write("testfile", "0123456789")      #=> 10
15658 #    # File would now read: "0123456789"
15659 def self.write(name, string, offset=0); 0; end
15660 ##
15661 # Same as <code>IO.write</code> except opening the file in binary mode
15662 # and ASCII-8BIT encoding ("wb:ASCII-8BIT").
15663 def self.binwrite(name, string, offset=0); 0; end
15664 ##
15665 # Calls select(2) system call.
15666 # It monitors given arrays of <code>IO</code> objects, waits one or more
15667 # of <code>IO</code> objects ready for reading, are ready for writing,
15668 # and have pending exceptions respectively, and returns an array that
15669 # contains arrays of those IO objects.  It will return <code>nil</code>
15670 # if optional <i>timeout</i> value is given and no <code>IO</code> object
15671 # is ready in <i>timeout</i> seconds.
15672 # 
15673 # === Parameters
15674 # read_array:: an array of <code>IO</code> objects that wait until ready for read
15675 # write_array:: an array of <code>IO</code> objects that wait until ready for write
15676 # error_array:: an array of <code>IO</code> objects that wait for exceptions
15677 # timeout:: a numeric value in second
15678 # 
15679 # === Example
15680 # 
15681 #     rp, wp = IO.pipe
15682 #     mesg = "ping "
15683 #     100.times {
15684 #       rs, ws, = IO.select([rp], [wp])
15685 #       if r = rs[0]
15686 #         ret = r.read(5)
15687 #         print ret
15688 #         case ret
15689 #         when /ping/
15690 #           mesg = "pong\n"
15691 #         when /pong/
15692 #           mesg = "ping "
15693 #         end
15694 #       end
15695 #       if w = ws[0]
15696 #         w.write(mesg)
15697 #       end
15698 #     }
15699 # 
15700 # <em>produces:</em>
15701 # 
15702 #     ping pong
15703 #     ping pong
15704 #     ping pong
15705 #     (snipped)
15706 #     ping
15707 def self.select(read_arra); [] || nil; end
15708 ##
15709 # Creates a pair of pipe endpoints (connected to each other) and
15710 # returns them as a two-element array of <code>IO</code> objects:
15711 # <code>[</code> <i>read_io</i>, <i>write_io</i> <code>]</code>.
15712 # 
15713 # If a block is given, the block is called and
15714 # returns the value of the block.
15715 # <i>read_io</i> and <i>write_io</i> are sent to the block as arguments.
15716 # If read_io and write_io are not closed when the block exits, they are closed.
15717 # i.e. closing read_io and/or write_io doesn't cause an error.
15718 # 
15719 # Not available on all platforms.
15720 # 
15721 # If an encoding (encoding name or encoding object) is specified as an optional argument,
15722 # read string from pipe is tagged with the encoding specified.
15723 # If the argument is a colon separated two encoding names "A:B",
15724 # the read string is converted from encoding A (external encoding)
15725 # to encoding B (internal encoding), then tagged with B.
15726 # If two optional arguments are specified, those must be
15727 # encoding objects or encoding names,
15728 # and the first one is the external encoding,
15729 # and the second one is the internal encoding.
15730 # If the external encoding and the internal encoding is specified,
15731 # optional hash argument specify the conversion option.
15732 # 
15733 # In the example below, the two processes close the ends of the pipe
15734 # that they are not using. This is not just a cosmetic nicety. The
15735 # read end of a pipe will not generate an end of file condition if
15736 # there are any writers with the pipe still open. In the case of the
15737 # parent process, the <code>rd.read</code> will never return if it
15738 # does not first issue a <code>wr.close</code>.
15739 # 
15740 #    rd, wr = IO.pipe
15741 # 
15742 #    if fork
15743 #      wr.close
15744 #      puts "Parent got: <#{rd.read}>"
15745 #      rd.close
15746 #      Process.wait
15747 #    else
15748 #      rd.close
15749 #      puts "Sending message to parent"
15750 #      wr.write "Hi Dad"
15751 #      wr.close
15752 #    end
15753 # 
15754 # <em>produces:</em>
15755 # 
15756 #    Sending message to parent
15757 #    Parent got: <Hi Dad>
15758 def self.pipe; end
15759 ##
15760 # Try to convert <i>obj</i> into an IO, using to_io method.
15761 # Returns converted IO or nil if <i>obj</i> cannot be converted
15762 # for any reason.
15763 # 
15764 #    IO.try_convert(STDOUT)     #=> STDOUT
15765 #    IO.try_convert("STDOUT")   #=> nil
15766 # 
15767 #    require 'zlib'
15768 #    f = open("/tmp/zz.gz")       #=> #<File:/tmp/zz.gz>
15769 #    z = Zlib::GzipReader.open(f) #=> #<Zlib::GzipReader:0x81d8744>
15770 #    IO.try_convert(z)            #=> #<File:/tmp/zz.gz>
15771 def self.try_convert(obj); IO.new || nil; end
15772 ##
15773 # IO.copy_stream copies <i>src</i> to <i>dst</i>.
15774 # <i>src</i> and <i>dst</i> is either a filename or an IO.
15775 # 
15776 # This method returns the number of bytes copied.
15777 # 
15778 # If optional arguments are not given,
15779 # the start position of the copy is
15780 # the beginning of the filename or
15781 # the current file offset of the IO.
15782 # The end position of the copy is the end of file.
15783 # 
15784 # If <i>copy_length</i> is given,
15785 # No more than <i>copy_length</i> bytes are copied.
15786 # 
15787 # If <i>src_offset</i> is given,
15788 # it specifies the start position of the copy.
15789 # 
15790 # When <i>src_offset</i> is specified and
15791 # <i>src</i> is an IO,
15792 # IO.copy_stream doesn't move the current file offset.
15793 def self.copy_stream(src, dst); end
15794 ##
15795 # Returns a new IO object (a stream) for the given integer file descriptor
15796 # +fd+ and +mode+ string.  +opt+ may be used to specify parts of +mode+ in a
15797 # more readable fashion.  See also IO.sysopen and IO.for_fd.
15798 # 
15799 # IO.new is called by various File and IO opening methods such as IO::open,
15800 # Kernel#open, and File::open.
15801 # 
15802 # === Open Mode
15803 # 
15804 # When +mode+ is an integer it must be combination of the modes defined in
15805 # File::Constants (+File::RDONLY+, +File::WRONLY | File::CREAT+).  See the
15806 # open(2) man page for more information.
15807 # 
15808 # When +mode+ is a string it must be in one of the following forms:
15809 # 
15810 #   fmode
15811 #   fmode ":" ext_enc
15812 #   fmode ":" ext_enc ":" int_enc
15813 #   fmode ":" "BOM|UTF-*"
15814 # 
15815 # +fmode+ is an IO open mode string, +ext_enc+ is the external encoding for
15816 # the IO and +int_enc+ is the internal encoding.
15817 # 
15818 # ==== IO Open Mode
15819 # 
15820 # Ruby allows the following open modes:
15821 # 
15822 #     "r"  Read-only, starts at beginning of file  (default mode).
15823 # 
15824 #     "r+" Read-write, starts at beginning of file.
15825 # 
15826 #     "w"  Write-only, truncates existing file
15827 #          to zero length or creates a new file for writing.
15828 # 
15829 #     "w+" Read-write, truncates existing file to zero length
15830 #          or creates a new file for reading and writing.
15831 # 
15832 #     "a"  Write-only, starts at end of file if file exists,
15833 #          otherwise creates a new file for writing.
15834 # 
15835 #     "a+" Read-write, starts at end of file if file exists,
15836 #          otherwise creates a new file for reading and
15837 #          writing.
15838 # 
15839 # The following modes must be used separately, and along with one or more of
15840 # the modes seen above.
15841 # 
15842 #     "b"  Binary file mode
15843 #          Suppresses EOL <-> CRLF conversion on Windows. And
15844 #          sets external encoding to ASCII-8BIT unless explicitly
15845 #          specified.
15846 # 
15847 #     "t"  Text file mode
15848 # 
15849 # When the open mode of original IO is read only, the mode cannot be
15850 # changed to be writable.  Similarly, the open mode cannot be changed from
15851 # write only to readable.
15852 # 
15853 # When such a change is attempted the error is raised in different locations
15854 # according to the platform.
15855 # 
15856 # === IO Encoding
15857 # 
15858 # When +ext_enc+ is specified, strings read will be tagged by the encoding
15859 # when reading, and strings output will be converted to the specified
15860 # encoding when writing.
15861 # 
15862 # When +ext_enc+ and +int_enc+ are specified read strings will be converted
15863 # from +ext_enc+ to +int_enc+ upon input, and written strings will be
15864 # converted from +int_enc+ to +ext_enc+ upon output.  See Encoding for
15865 # further details of transcoding on input and output.
15866 # 
15867 # If "BOM|UTF-8", "BOM|UTF-16LE" or "BOM|UTF16-BE" are used, ruby checks for
15868 # a Unicode BOM in the input document to help determine the encoding.  For
15869 # UTF-16 encodings the file open mode must be binary.  When present, the BOM
15870 # is stripped and the external encoding from the BOM is used.  When the BOM
15871 # is missing the given Unicode encoding is used as +ext_enc+.  (The BOM-set
15872 # encoding option is case insensitive, so "bom|utf-8" is also valid.)
15873 # 
15874 # === Options
15875 # 
15876 # +opt+ can be used instead of +mode+ for improved readability.  The
15877 # following keys are supported:
15878 # 
15879 # :mode ::
15880 #   Same as +mode+ parameter
15881 # 
15882 # :\external_encoding ::
15883 #   External encoding for the IO.  "-" is a synonym for the default external
15884 #   encoding.
15885 # 
15886 # :\internal_encoding ::
15887 #   Internal encoding for the IO.  "-" is a synonym for the default internal
15888 #   encoding.
15889 # 
15890 #   If the value is nil no conversion occurs.
15891 # 
15892 # :encoding ::
15893 #   Specifies external and internal encodings as "extern:intern".
15894 # 
15895 # :textmode ::
15896 #   If the value is truth value, same as "t" in argument +mode+.
15897 # 
15898 # :binmode ::
15899 #   If the value is truth value, same as "b" in argument +mode+.
15900 # 
15901 # :autoclose ::
15902 #   If the value is +false+, the +fd+ will be kept open after this IO
15903 #   instance gets finalized.
15904 # 
15905 # Also, +opt+ can have same keys in String#encode for controlling conversion
15906 # between the external encoding and the internal encoding.
15907 # 
15908 # === Example 1
15909 # 
15910 #   fd = IO.sysopen("/dev/tty", "w")
15911 #   a = IO.new(fd,"w")
15912 #   $stderr.puts "Hello"
15913 #   a.puts "World"
15914 # 
15915 # Produces:
15916 # 
15917 #   Hello
15918 #   World
15919 # 
15920 # === Example 2
15921 # 
15922 #   require 'fcntl'
15923 # 
15924 #   fd = STDERR.fcntl(Fcntl::F_DUPFD)
15925 #   io = IO.new(fd, mode: 'w:UTF-16LE', cr_newline: true)
15926 #   io.puts "Hello, World!"
15927 # 
15928 #   fd = STDERR.fcntl(Fcntl::F_DUPFD)
15929 #   io = IO.new(fd, mode: 'w', cr_newline: true,
15930 #               external_encoding: Encoding::UTF_16LE)
15931 #   io.puts "Hello, World!"
15932 # 
15933 # Both of above print "Hello, World!" in UTF-16LE to standard error output
15934 # with converting EOL generated by <code>puts</code> to CR.
15935 def self.new(fd , mode=0, opt=0); end
15936 ##
15937 # Reassociates <em>ios</em> with the I/O stream given in
15938 # <i>other_IO</i> or to a new stream opened on <i>path</i>. This may
15939 # dynamically change the actual class of this stream.
15940 # 
15941 #    f1 = File.new("testfile")
15942 #    f2 = File.new("testfile")
15943 #    f2.readlines[0]   #=> "This is line one\n"
15944 #    f2.reopen(f1)     #=> #<File:testfile>
15945 #    f2.readlines[0]   #=> "This is line one\n"
15946 def reopen(other_IO); IO.new; end
15947 ##
15948 # Writes the given object(s) to <em>ios</em>. The stream must be
15949 # opened for writing. If the output field separator (<code>$,</code>)
15950 # is not <code>nil</code>, it will be inserted between each object.
15951 # If the output record separator (<code>$\\</code>)
15952 # is not <code>nil</code>, it will be appended to the output. If no
15953 # arguments are given, prints <code>$_</code>. Objects that aren't
15954 # strings will be converted by calling their <code>to_s</code> method.
15955 # With no argument, prints the contents of the variable <code>$_</code>.
15956 # Returns <code>nil</code>.
15957 # 
15958 #    $stdout.print("This is ", 100, " percent.\n")
15959 # 
15960 # <em>produces:</em>
15961 # 
15962 #    This is 100 percent.
15963 def print(); end
15964 ##
15965 # If <i>obj</i> is <code>Numeric</code>, write the character whose code is
15966 # the least-significant byte of <i>obj</i>, otherwise write the first byte
15967 # of the string representation of <i>obj</i> to <em>ios</em>. Note: This
15968 # method is not safe for use with multi-byte characters as it will truncate
15969 # them.
15970 # 
15971 #    $stdout.putc "A"
15972 #    $stdout.putc 65
15973 # 
15974 # <em>produces:</em>
15975 # 
15976 #    AA
15977 def putc(obj); Object.new; end
15978 ##
15979 # Writes the given objects to <em>ios</em> as with
15980 # <code>IO#print</code>. Writes a record separator (typically a
15981 # newline) after any that do not already end with a newline sequence.
15982 # If called with an array argument, writes each element on a new line.
15983 # If called without arguments, outputs a single record separator.
15984 # 
15985 #    $stdout.puts("this", "is", "a", "test")
15986 # 
15987 # <em>produces:</em>
15988 # 
15989 #    this
15990 #    is
15991 #    a
15992 #    test
15993 def puts(); end
15994 ##
15995 # Formats and writes to <em>ios</em>, converting parameters under
15996 # control of the format string. See <code>Kernel#sprintf</code>
15997 # for details.
15998 def printf(format_string , obj=0); end
15999 ##
16000 # Executes the block for every line in <em>ios</em>, where lines are
16001 # separated by <i>sep</i>. <em>ios</em> must be opened for
16002 # reading or an <code>IOError</code> will be raised.
16003 # 
16004 # If no block is given, an enumerator is returned instead.
16005 # 
16006 #    f = File.new("testfile")
16007 #    f.each {|line| puts "#{f.lineno}: #{line}" }
16008 # 
16009 # <em>produces:</em>
16010 # 
16011 #    1: This is line one
16012 #    2: This is line two
16013 #    3: This is line three
16014 #    4: And so on...
16015 def each(sep=$/, &block); Enumerator.new; end
16016 ##
16017 # Executes the block for every line in <em>ios</em>, where lines are
16018 # separated by <i>sep</i>. <em>ios</em> must be opened for
16019 # reading or an <code>IOError</code> will be raised.
16020 # 
16021 # If no block is given, an enumerator is returned instead.
16022 # 
16023 #    f = File.new("testfile")
16024 #    f.each {|line| puts "#{f.lineno}: #{line}" }
16025 # 
16026 # <em>produces:</em>
16027 # 
16028 #    1: This is line one
16029 #    2: This is line two
16030 #    3: This is line three
16031 #    4: And so on...
16032 def each_line(sep=$/, &block); Enumerator.new; end
16033 ##
16034 # Calls the given block once for each byte (0..255) in <em>ios</em>,
16035 # passing the byte as an argument. The stream must be opened for
16036 # reading or an <code>IOError</code> will be raised.
16037 # 
16038 # If no block is given, an enumerator is returned instead.
16039 # 
16040 #    f = File.new("testfile")
16041 #    checksum = 0
16042 #    f.each_byte {|x| checksum ^= x }   #=> #<File:testfile>
16043 #    checksum                           #=> 12
16044 def each_byte(&block); Enumerator.new; end
16045 ##
16046 # Calls the given block once for each character in <em>ios</em>,
16047 # passing the character as an argument. The stream must be opened for
16048 # reading or an <code>IOError</code> will be raised.
16049 # 
16050 # If no block is given, an enumerator is returned instead.
16051 # 
16052 #    f = File.new("testfile")
16053 #    f.each_char {|c| print c, ' ' }   #=> #<File:testfile>
16054 def each_char(&block); Enumerator.new; end
16055 ##
16056 # Passes the <code>Integer</code> ordinal of each character in <i>ios</i>,
16057 # passing the codepoint as an argument. The stream must be opened for
16058 # reading or an <code>IOError</code> will be raised.
16059 # 
16060 # If no block is given, an enumerator is returned instead.
16061 def each_codepoint(&block); Enumerator.new; end
16062 ##
16063 # Passes the <code>Integer</code> ordinal of each character in <i>ios</i>,
16064 # passing the codepoint as an argument. The stream must be opened for
16065 # reading or an <code>IOError</code> will be raised.
16066 # 
16067 # If no block is given, an enumerator is returned instead.
16068 def codepoints(&block); Enumerator.new; end
16069 ##
16070 # Writes the given string to <em>ios</em> using a low-level write.
16071 # Returns the number of bytes written. Do not mix with other methods
16072 # that write to <em>ios</em> or you may get unpredictable results.
16073 # Raises <code>SystemCallError</code> on error.
16074 # 
16075 #    f = File.new("out", "w")
16076 #    f.syswrite("ABCDEF")   #=> 6
16077 def syswrite(string); 0; end
16078 ##
16079 # Reads <i>maxlen</i> bytes from <em>ios</em> using a low-level
16080 # read and returns them as a string.  Do not mix with other methods
16081 # that read from <em>ios</em> or you may get unpredictable results.
16082 # If the optional <i>outbuf</i> argument is present, it must reference
16083 # a String, which will receive the data.
16084 # The <i>outbuf</i> will contain only the received data after the method call
16085 # even if it is not empty at the beginning.
16086 # Raises <code>SystemCallError</code> on error and
16087 # <code>EOFError</code> at end of file.
16088 # 
16089 #    f = File.new("testfile")
16090 #    f.sysread(16)   #=> "This is line one"
16091 def sysread(maxlen, outbuf=0); ''; end
16092 ##
16093 # Returns an integer representing the numeric file descriptor for
16094 # <em>ios</em>.
16095 # 
16096 #    $stdin.fileno    #=> 0
16097 #    $stdout.fileno   #=> 1
16098 def fileno; 0; end
16099 ##
16100 # Returns an integer representing the numeric file descriptor for
16101 # <em>ios</em>.
16102 # 
16103 #    $stdin.fileno    #=> 0
16104 #    $stdout.fileno   #=> 1
16105 def to_i; 0; end
16106 ##
16107 # Returns <em>ios</em>.
16108 def to_io; IO.new; end
16109 ##
16110 # Immediately writes all buffered data in <em>ios</em> to disk.
16111 # Note that <code>fsync</code> differs from
16112 # using <code>IO#sync=</code>. The latter ensures that data is flushed
16113 # from Ruby's buffers, but does not guarantee that the underlying
16114 # operating system actually writes it to disk.
16115 # 
16116 # <code>NotImplementedError</code> is raised
16117 # if the underlying operating system does not support <em>fsync(2)</em>.
16118 def fsync; 0 || nil; end
16119 ##
16120 # Immediately writes all buffered data in <em>ios</em> to disk.
16121 # 
16122 # If the underlying operating system does not support <em>fdatasync(2)</em>,
16123 # <code>IO#fsync</code> is called instead (which might raise a
16124 # <code>NotImplementedError</code>).
16125 def fdatasync; 0 || nil; end
16126 ##
16127 # Returns the current ``sync mode'' of <em>ios</em>. When sync mode is
16128 # true, all output is immediately flushed to the underlying operating
16129 # system and is not buffered by Ruby internally. See also
16130 # <code>IO#fsync</code>.
16131 # 
16132 #    f = File.new("testfile")
16133 #    f.sync   #=> false
16134 def sync; true || false; end
16135 ##
16136 # Sets the ``sync mode'' to <code>true</code> or <code>false</code>.
16137 # When sync mode is true, all output is immediately flushed to the
16138 # underlying operating system and is not buffered internally. Returns
16139 # the new state. See also <code>IO#fsync</code>.
16140 # 
16141 #    f = File.new("testfile")
16142 #    f.sync = true
16143 # 
16144 # <em>(produces no output)</em>
16145 def sync= boolean; true || false; end
16146 ##
16147 # Returns the current line number in <em>ios</em>.  The stream must be
16148 # opened for reading. <code>lineno</code> counts the number of times
16149 # #gets is called rather than the number of newlines encountered.  The two
16150 # values will differ if #gets is called with a separator other than newline.
16151 # 
16152 # Methods that use <code>$/</code> like #each, #lines and #readline will
16153 # also increment <code>lineno</code>.
16154 # 
16155 # See also the <code>$.</code> variable.
16156 # 
16157 #    f = File.new("testfile")
16158 #    f.lineno   #=> 0
16159 #    f.gets     #=> "This is line one\n"
16160 #    f.lineno   #=> 1
16161 #    f.gets     #=> "This is line two\n"
16162 #    f.lineno   #=> 2
16163 def lineno; 0; end
16164 ##
16165 # Manually sets the current line number to the given value.
16166 # <code>$.</code> is updated only on the next read.
16167 # 
16168 #    f = File.new("testfile")
16169 #    f.gets                     #=> "This is line one\n"
16170 #    $.                         #=> 1
16171 #    f.lineno = 1000
16172 #    f.lineno                   #=> 1000
16173 #    $.                         #=> 1         # lineno of last read
16174 #    f.gets                     #=> "This is line two\n"
16175 #    $.                         #=> 1001      # lineno of last read
16176 def lineno= integer; 0; end
16177 ##
16178 # Reads at most <i>maxlen</i> bytes from <em>ios</em> using
16179 # the read(2) system call after O_NONBLOCK is set for
16180 # the underlying file descriptor.
16181 # 
16182 # If the optional <i>outbuf</i> argument is present,
16183 # it must reference a String, which will receive the data.
16184 # The <i>outbuf</i> will contain only the received data after the method call
16185 # even if it is not empty at the beginning.
16186 # 
16187 # read_nonblock just calls the read(2) system call.
16188 # It causes all errors the read(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
16189 # The caller should care such errors.
16190 # 
16191 # If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
16192 # it is extended by IO::WaitReadable.
16193 # So IO::WaitReadable can be used to rescue the exceptions for retrying read_nonblock.
16194 # 
16195 # read_nonblock causes EOFError on EOF.
16196 # 
16197 # If the read byte buffer is not empty,
16198 # read_nonblock reads from the buffer like readpartial.
16199 # In this case, the read(2) system call is not called.
16200 # 
16201 # When read_nonblock raises an exception kind of IO::WaitReadable,
16202 # read_nonblock should not be called
16203 # until io is readable for avoiding busy loop.
16204 # This can be done as follows.
16205 # 
16206 #   # emulates blocking read (readpartial).
16207 #   begin
16208 #     result = io.read_nonblock(maxlen)
16209 #   rescue IO::WaitReadable
16210 #     IO.select([io])
16211 #     retry
16212 #   end
16213 # 
16214 # Although IO#read_nonblock doesn't raise IO::WaitWritable.
16215 # OpenSSL::Buffering#read_nonblock can raise IO::WaitWritable.
16216 # If IO and SSL should be used polymorphically,
16217 # IO::WaitWritable should be rescued too.
16218 # See the document of OpenSSL::Buffering#read_nonblock for sample code.
16219 # 
16220 # Note that this method is identical to readpartial
16221 # except the non-blocking flag is set.
16222 def read_nonblock(maxlen); ''; end
16223 ##
16224 # Writes the given string to <em>ios</em> using
16225 # the write(2) system call after O_NONBLOCK is set for
16226 # the underlying file descriptor.
16227 # 
16228 # It returns the number of bytes written.
16229 # 
16230 # write_nonblock just calls the write(2) system call.
16231 # It causes all errors the write(2) system call causes: Errno::EWOULDBLOCK, Errno::EINTR, etc.
16232 # The result may also be smaller than string.length (partial write).
16233 # The caller should care such errors and partial write.
16234 # 
16235 # If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
16236 # it is extended by IO::WaitWritable.
16237 # So IO::WaitWritable can be used to rescue the exceptions for retrying write_nonblock.
16238 # 
16239 #   # Creates a pipe.
16240 #   r, w = IO.pipe
16241 # 
16242 #   # write_nonblock writes only 65536 bytes and return 65536.
16243 #   # (The pipe size is 65536 bytes on this environment.)
16244 #   s = "a" * 100000
16245 #   p w.write_nonblock(s)     #=> 65536
16246 # 
16247 #   # write_nonblock cannot write a byte and raise EWOULDBLOCK (EAGAIN).
16248 #   p w.write_nonblock("b")   # Resource temporarily unavailable (Errno::EAGAIN)
16249 # 
16250 # If the write buffer is not empty, it is flushed at first.
16251 # 
16252 # When write_nonblock raises an exception kind of IO::WaitWritable,
16253 # write_nonblock should not be called
16254 # until io is writable for avoiding busy loop.
16255 # This can be done as follows.
16256 # 
16257 #   begin
16258 #     result = io.write_nonblock(string)
16259 #   rescue IO::WaitWritable, Errno::EINTR
16260 #     IO.select(nil, [io])
16261 #     retry
16262 #   end
16263 # 
16264 # Note that this doesn't guarantee to write all data in string.
16265 # The length written is reported as result and it should be checked later.
16266 # 
16267 # On some platforms such as Windows, write_nonblock is not supported
16268 # according to the kind of the IO object.
16269 # In such cases, write_nonblock raises <code>Errno::EBADF</code>.
16270 def write_nonblock(string); 0; end
16271 ##
16272 # Reads at most <i>maxlen</i> bytes from the I/O stream.
16273 # It blocks only if <em>ios</em> has no data immediately available.
16274 # It doesn't block if some data available.
16275 # If the optional <i>outbuf</i> argument is present,
16276 # it must reference a String, which will receive the data.
16277 # The <i>outbuf</i> will contain only the received data after the method call
16278 # even if it is not empty at the beginning.
16279 # It raises <code>EOFError</code> on end of file.
16280 # 
16281 # readpartial is designed for streams such as pipe, socket, tty, etc.
16282 # It blocks only when no data immediately available.
16283 # This means that it blocks only when following all conditions hold.
16284 # * the byte buffer in the IO object is empty.
16285 # * the content of the stream is empty.
16286 # * the stream is not reached to EOF.
16287 # 
16288 # When readpartial blocks, it waits data or EOF on the stream.
16289 # If some data is reached, readpartial returns with the data.
16290 # If EOF is reached, readpartial raises EOFError.
16291 # 
16292 # When readpartial doesn't blocks, it returns or raises immediately.
16293 # If the byte buffer is not empty, it returns the data in the buffer.
16294 # Otherwise if the stream has some content,
16295 # it returns the data in the stream.
16296 # Otherwise if the stream is reached to EOF, it raises EOFError.
16297 # 
16298 #    r, w = IO.pipe           #               buffer          pipe content
16299 #    w << "abc"               #               ""              "abc".
16300 #    r.readpartial(4096)      #=> "abc"       ""              ""
16301 #    r.readpartial(4096)      # blocks because buffer and pipe is empty.
16302 # 
16303 #    r, w = IO.pipe           #               buffer          pipe content
16304 #    w << "abc"               #               ""              "abc"
16305 #    w.close                  #               ""              "abc" EOF
16306 #    r.readpartial(4096)      #=> "abc"       ""              EOF
16307 #    r.readpartial(4096)      # raises EOFError
16308 # 
16309 #    r, w = IO.pipe           #               buffer          pipe content
16310 #    w << "abc\ndef\n"        #               ""              "abc\ndef\n"
16311 #    r.gets                   #=> "abc\n"     "def\n"         ""
16312 #    w << "ghi\n"             #               "def\n"         "ghi\n"
16313 #    r.readpartial(4096)      #=> "def\n"     ""              "ghi\n"
16314 #    r.readpartial(4096)      #=> "ghi\n"     ""              ""
16315 # 
16316 # Note that readpartial behaves similar to sysread.
16317 # The differences are:
16318 # * If the byte buffer is not empty, read from the byte buffer instead of "sysread for buffered IO (IOError)".
16319 # * It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR.  When readpartial meets EWOULDBLOCK and EINTR by read system call, readpartial retry the system call.
16320 # 
16321 # The later means that readpartial is nonblocking-flag insensitive.
16322 # It blocks on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking mode.
16323 def readpartial(maxlen); ''; end
16324 ##
16325 # Reads the next ``line'' from the I/O stream; lines are separated by
16326 # <i>sep</i>. A separator of <code>nil</code> reads the entire
16327 # contents, and a zero-length separator reads the input a paragraph at
16328 # a time (two successive newlines in the input separate paragraphs).
16329 # The stream must be opened for reading or an <code>IOError</code>
16330 # will be raised. The line read in will be returned and also assigned
16331 # to <code>$_</code>. Returns <code>nil</code> if called at end of
16332 # file.  If the first argument is an integer, or optional second
16333 # argument is given, the returning string would not be longer than the
16334 # given value in bytes.
16335 # 
16336 #    File.new("testfile").gets   #=> "This is line one\n"
16337 #    $_                          #=> "This is line one\n"
16338 def gets(sep=$/); '' || nil; end
16339 ##
16340 # Reads a line as with <code>IO#gets</code>, but raises an
16341 # <code>EOFError</code> on end of file.
16342 def readline(sep=$/); ''; end
16343 ##
16344 # Reads a one-character string from <em>ios</em>. Returns
16345 # <code>nil</code> if called at end of file.
16346 # 
16347 #    f = File.new("testfile")
16348 #    f.getc   #=> "h"
16349 #    f.getc   #=> "e"
16350 def getc; '' || nil; end
16351 ##
16352 # Gets the next 8-bit byte (0..255) from <em>ios</em>. Returns
16353 # <code>nil</code> if called at end of file.
16354 # 
16355 #    f = File.new("testfile")
16356 #    f.getbyte   #=> 84
16357 #    f.getbyte   #=> 104
16358 def getbyte; 1 || nil; end
16359 ##
16360 # Reads a one-character string from <em>ios</em>. Raises an
16361 # <code>EOFError</code> on end of file.
16362 # 
16363 #    f = File.new("testfile")
16364 #    f.readchar   #=> "h"
16365 #    f.readchar   #=> "e"
16366 def readchar; ''; end
16367 ##
16368 # Reads a byte as with <code>IO#getbyte</code>, but raises an
16369 # <code>EOFError</code> on end of file.
16370 def readbyte; 0; end
16371 ##
16372 # Pushes back bytes (passed as a parameter) onto <em>ios</em>,
16373 # such that a subsequent buffered read will return it. Only one byte
16374 # may be pushed back before a subsequent read operation (that is,
16375 # you will be able to read only the last of several bytes that have been pushed
16376 # back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
16377 # 
16378 #    f = File.new("testfile")   #=> #<File:testfile>
16379 #    b = f.getbyte              #=> 0x38
16380 #    f.ungetbyte(b)             #=> nil
16381 #    f.getbyte                  #=> 0x38
16382 def ungetbyte(string); end
16383 ##
16384 # Pushes back one character (passed as a parameter) onto <em>ios</em>,
16385 # such that a subsequent buffered character read will return it. Only one character
16386 # may be pushed back before a subsequent read operation (that is,
16387 # you will be able to read only the last of several characters that have been pushed
16388 # back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
16389 # 
16390 #    f = File.new("testfile")   #=> #<File:testfile>
16391 #    c = f.getc                 #=> "8"
16392 #    f.ungetc(c)                #=> nil
16393 #    f.getc                     #=> "8"
16394 def ungetc(string); end
16395 ##
16396 # String Output---Writes <i>obj</i> to <em>ios</em>.
16397 # <i>obj</i> will be converted to a string using
16398 # <code>to_s</code>.
16399 # 
16400 #    $stdout << "Hello " << "world!\n"
16401 # 
16402 # <em>produces:</em>
16403 # 
16404 #    Hello world!
16405 def <<; IO.new; end
16406 ##
16407 # Flushes any buffered data within <em>ios</em> to the underlying
16408 # operating system (note that this is Ruby internal buffering only;
16409 # the OS may buffer the data as well).
16410 # 
16411 #    $stdout.print "no newline"
16412 #    $stdout.flush
16413 # 
16414 # <em>produces:</em>
16415 # 
16416 #    no newline
16417 def flush; IO.new; end
16418 ##
16419 # Returns the current offset (in bytes) of <em>ios</em>.
16420 # 
16421 #    f = File.new("testfile")
16422 #    f.pos    #=> 0
16423 #    f.gets   #=> "This is line one\n"
16424 #    f.pos    #=> 17
16425 def pos; 0; end
16426 ##
16427 # Returns the current offset (in bytes) of <em>ios</em>.
16428 # 
16429 #    f = File.new("testfile")
16430 #    f.pos    #=> 0
16431 #    f.gets   #=> "This is line one\n"
16432 #    f.pos    #=> 17
16433 def tell; 0; end
16434 ##
16435 # Seeks to a given offset <i>anInteger</i> in the stream according to
16436 # the value of <i>whence</i>:
16437 # 
16438 #   IO::SEEK_CUR  | Seeks to _amount_ plus current position
16439 #   --------------+----------------------------------------------------
16440 #   IO::SEEK_END  | Seeks to _amount_ plus end of stream (you probably
16441 #                 | want a negative value for _amount_)
16442 #   --------------+----------------------------------------------------
16443 #   IO::SEEK_SET  | Seeks to the absolute location given by _amount_
16444 # 
16445 # Example:
16446 # 
16447 #    f = File.new("testfile")
16448 #    f.seek(-13, IO::SEEK_END)   #=> 0
16449 #    f.readline                  #=> "And so on...\n"
16450 def seek(amount, whence=IO::SEEK_SET); 0; end
16451 ##
16452 # Positions <em>ios</em> to the beginning of input, resetting
16453 # <code>lineno</code> to zero.
16454 # 
16455 #    f = File.new("testfile")
16456 #    f.readline   #=> "This is line one\n"
16457 #    f.rewind     #=> 0
16458 #    f.lineno     #=> 0
16459 #    f.readline   #=> "This is line one\n"
16460 # 
16461 # Note that it cannot be used with streams such as pipes, ttys, and sockets.
16462 def rewind; 0; end
16463 ##
16464 # Seeks to the given position (in bytes) in <em>ios</em>.
16465 # It is not guranteed that seeking to the right position when <em>ios</em>
16466 # is textmode.
16467 # 
16468 #    f = File.new("testfile")
16469 #    f.pos = 17
16470 #    f.gets   #=> "This is line two\n"
16471 def pos= integer; 0; end
16472 ##
16473 # Returns true if <em>ios</em> is at end of file that means
16474 # there are no more data to read.
16475 # The stream must be opened for reading or an <code>IOError</code> will be
16476 # raised.
16477 # 
16478 #    f = File.new("testfile")
16479 #    dummy = f.readlines
16480 #    f.eof   #=> true
16481 # 
16482 # If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code>
16483 # blocks until the other end sends some data or closes it.
16484 # 
16485 #    r, w = IO.pipe
16486 #    Thread.new { sleep 1; w.close }
16487 #    r.eof?  #=> true after 1 second blocking
16488 # 
16489 #    r, w = IO.pipe
16490 #    Thread.new { sleep 1; w.puts "a" }
16491 #    r.eof?  #=> false after 1 second blocking
16492 # 
16493 #    r, w = IO.pipe
16494 #    r.eof?  # blocks forever
16495 # 
16496 # Note that <code>IO#eof?</code> reads data to the input byte buffer.
16497 # So <code>IO#sysread</code> may not behave as you intend with
16498 # <code>IO#eof?</code>, unless you call <code>IO#rewind</code>
16499 # first (which is not available for some streams).
16500 def eof; true || false; end
16501 ##
16502 # Returns true if <em>ios</em> is at end of file that means
16503 # there are no more data to read.
16504 # The stream must be opened for reading or an <code>IOError</code> will be
16505 # raised.
16506 # 
16507 #    f = File.new("testfile")
16508 #    dummy = f.readlines
16509 #    f.eof   #=> true
16510 # 
16511 # If <em>ios</em> is a stream such as pipe or socket, <code>IO#eof?</code>
16512 # blocks until the other end sends some data or closes it.
16513 # 
16514 #    r, w = IO.pipe
16515 #    Thread.new { sleep 1; w.close }
16516 #    r.eof?  #=> true after 1 second blocking
16517 # 
16518 #    r, w = IO.pipe
16519 #    Thread.new { sleep 1; w.puts "a" }
16520 #    r.eof?  #=> false after 1 second blocking
16521 # 
16522 #    r, w = IO.pipe
16523 #    r.eof?  # blocks forever
16524 # 
16525 # Note that <code>IO#eof?</code> reads data to the input byte buffer.
16526 # So <code>IO#sysread</code> may not behave as you intend with
16527 # <code>IO#eof?</code>, unless you call <code>IO#rewind</code>
16528 # first (which is not available for some streams).
16529 def eof?; true || false; end
16530 ##
16531 # Returns <code>true</code> if <em>ios</em> will be closed on exec.
16532 # 
16533 #    f = open("/dev/null")
16534 #    f.close_on_exec?                 #=> false
16535 #    f.close_on_exec = true
16536 #    f.close_on_exec?                 #=> true
16537 #    f.close_on_exec = false
16538 #    f.close_on_exec?                 #=> false
16539 def close_on_exec?; true || false; end
16540 ##
16541 # Sets a close-on-exec flag.
16542 # 
16543 #    f = open("/dev/null")
16544 #    f.close_on_exec = true
16545 #    system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
16546 #    f.closed?                #=> false
16547 # 
16548 # Ruby sets close-on-exec flags of all file descriptors by default
16549 # since Ruby 2.0.0.
16550 # So you don't need to set by yourself.
16551 # Also, unsetting a close-on-exec flag can cause file descriptor leak
16552 # if another thread use fork() and exec() (via system() method for example).
16553 # If you really needs file descriptor inheritance to child process,
16554 # use spawn()'s argument such as fd=>fd.
16555 def close_on_exec= bool; true || false; end
16556 ##
16557 # Closes <em>ios</em> and flushes any pending writes to the operating
16558 # system. The stream is unavailable for any further data operations;
16559 # an <code>IOError</code> is raised if such an attempt is made. I/O
16560 # streams are automatically closed when they are claimed by the
16561 # garbage collector.
16562 # 
16563 # If <em>ios</em> is opened by <code>IO.popen</code>,
16564 # <code>close</code> sets <code>$?</code>.
16565 def close; end
16566 ##
16567 # Returns <code>true</code> if <em>ios</em> is completely closed (for
16568 # duplex streams, both reader and writer), <code>false</code>
16569 # otherwise.
16570 # 
16571 #    f = File.new("testfile")
16572 #    f.close         #=> nil
16573 #    f.closed?       #=> true
16574 #    f = IO.popen("/bin/sh","r+")
16575 #    f.close_write   #=> nil
16576 #    f.closed?       #=> false
16577 #    f.close_read    #=> nil
16578 #    f.closed?       #=> true
16579 def closed?; true || false; end
16580 ##
16581 # Closes the read end of a duplex I/O stream (i.e., one that contains
16582 # both a read and a write stream, such as a pipe). Will raise an
16583 # <code>IOError</code> if the stream is not duplexed.
16584 # 
16585 #    f = IO.popen("/bin/sh","r+")
16586 #    f.close_read
16587 #    f.readlines
16588 # 
16589 # <em>produces:</em>
16590 # 
16591 #    prog.rb:3:in `readlines': not opened for reading (IOError)
16592 #     from prog.rb:3
16593 def close_read; end
16594 ##
16595 # Closes the write end of a duplex I/O stream (i.e., one that contains
16596 # both a read and a write stream, such as a pipe). Will raise an
16597 # <code>IOError</code> if the stream is not duplexed.
16598 # 
16599 #    f = IO.popen("/bin/sh","r+")
16600 #    f.close_write
16601 #    f.print "nowhere"
16602 # 
16603 # <em>produces:</em>
16604 # 
16605 #    prog.rb:3:in `write': not opened for writing (IOError)
16606 #     from prog.rb:3:in `print'
16607 #     from prog.rb:3
16608 def close_write; end
16609 ##
16610 # Returns <code>true</code> if <em>ios</em> is associated with a
16611 # terminal device (tty), <code>false</code> otherwise.
16612 # 
16613 #    File.new("testfile").isatty   #=> false
16614 #    File.new("/dev/tty").isatty   #=> true
16615 def isatty; true || false; end
16616 ##
16617 # Returns <code>true</code> if <em>ios</em> is associated with a
16618 # terminal device (tty), <code>false</code> otherwise.
16619 # 
16620 #    File.new("testfile").isatty   #=> false
16621 #    File.new("/dev/tty").isatty   #=> true
16622 def tty?; true || false; end
16623 ##
16624 # Puts <em>ios</em> into binary mode.
16625 # Once a stream is in binary mode, it cannot be reset to nonbinary mode.
16626 # 
16627 # - newline conversion disabled
16628 # - encoding conversion disabled
16629 # - content is treated as ASCII-8BIT
16630 def binmode; IO.new; end
16631 ##
16632 # Returns <code>true</code> if <em>ios</em> is binmode.
16633 def binmode?; true || false; end
16634 ##
16635 # Seeks to a given <i>offset</i> in the stream according to the value
16636 # of <i>whence</i> (see <code>IO#seek</code> for values of
16637 # <i>whence</i>). Returns the new offset into the file.
16638 # 
16639 #    f = File.new("testfile")
16640 #    f.sysseek(-13, IO::SEEK_END)   #=> 53
16641 #    f.sysread(10)                  #=> "And so on."
16642 def sysseek(offset, whence=IO::SEEK_SET); 0; end
16643 ##
16644 #  Announce an intention to access data from the current file in a
16645 #  specific pattern. On platforms that do not support the
16646 #  <em>posix_fadvise(2)</em> system call, this method is a no-op.
16647 # 
16648 # _advice_ is one of the following symbols:
16649 # 
16650 #  * :normal - No advice to give; the default assumption for an open file.
16651 #  * :sequential - The data will be accessed sequentially:
16652 #     with lower offsets read before higher ones.
16653 #  * :random - The data will be accessed in random order.
16654 #  * :willneed - The data will be accessed in the near future.
16655 #  * :dontneed - The data will not be accessed in the near future.
16656 #  * :noreuse - The data will only be accessed once.
16657 # 
16658 # The semantics of a piece of advice are platform-dependent. See
16659 # <em>man 2 posix_fadvise</em> for details.
16660 # 
16661 #  "data" means the region of the current file that begins at
16662 #  _offset_ and extends for _len_ bytes. If _len_ is 0, the region
16663 #  ends at the last byte of the file. By default, both _offset_ and
16664 #  _len_ are 0, meaning that the advice applies to the entire file.
16665 # 
16666 #  If an error occurs, one of the following exceptions will be raised:
16667 # 
16668 #  * <code>IOError</code> - The <code>IO</code> stream is closed.
16669 #  * <code>Errno::EBADF</code> - The file descriptor of the current file is
16670 #    invalid.
16671 #  * <code>Errno::EINVAL</code> - An invalid value for _advice_ was given.
16672 #  * <code>Errno::ESPIPE</code> - The file descriptor of the current
16673 #  * file refers to a FIFO or pipe. (Linux raises <code>Errno::EINVAL</code>
16674 #  * in this case).
16675 #  * <code>TypeError</code> - Either _advice_ was not a Symbol, or one of the
16676 #    other arguments was not an <code>Integer</code>.
16677 #  * <code>RangeError</code> - One of the arguments given was too big/small.
16678 # 
16679 # This list is not exhaustive; other Errno:: exceptions are also possible.
16680 def advise(advice, offset=0, len=0); end
16681 ##
16682 # Provides a mechanism for issuing low-level commands to control or
16683 # query I/O devices. Arguments and results are platform dependent. If
16684 # <i>arg</i> is a number, its value is passed directly. If it is a
16685 # string, it is interpreted as a binary sequence of bytes. On Unix
16686 # platforms, see <code>ioctl(2)</code> for details. Not implemented on
16687 # all platforms.
16688 def ioctl(integer_cmd, arg); 0; end
16689 ##
16690 # Provides a mechanism for issuing low-level commands to control or
16691 # query file-oriented I/O streams. Arguments and results are platform
16692 # dependent. If <i>arg</i> is a number, its value is passed
16693 # directly. If it is a string, it is interpreted as a binary sequence
16694 # of bytes (<code>Array#pack</code> might be a useful way to build this
16695 # string). On Unix platforms, see <code>fcntl(2)</code> for details.
16696 # Not implemented on all platforms.
16697 def fcntl(integer_cmd, arg); 0; end
16698 ##
16699 # Returns the process ID of a child process associated with
16700 # <em>ios</em>. This will be set by <code>IO.popen</code>.
16701 # 
16702 #    pipe = IO.popen("-")
16703 #    if pipe
16704 #      $stderr.puts "In parent, child pid is #{pipe.pid}"
16705 #    else
16706 #      $stderr.puts "In child, pid is #{$$}"
16707 #    end
16708 # 
16709 # <em>produces:</em>
16710 # 
16711 #    In child, pid is 26209
16712 #    In parent, child pid is 26209
16713 def pid; 0; end
16714 ##
16715 # Return a string describing this IO object.
16716 def inspect; ''; end
16717 ##
16718 # Returns the Encoding object that represents the encoding of the file.
16719 # If io is write mode and no encoding is specified, returns <code>nil</code>.
16720 def external_encoding; Encoding.new; end
16721 ##
16722 # Returns the Encoding of the internal string if conversion is
16723 # specified.  Otherwise returns nil.
16724 def internal_encoding; Encoding.new; end
16725 ##
16726 # If single argument is specified, read string from io is tagged
16727 # with the encoding specified.  If encoding is a colon separated two
16728 # encoding names "A:B", the read string is converted from encoding A
16729 # (external encoding) to encoding B (internal encoding), then tagged
16730 # with B.  If two arguments are specified, those must be encoding
16731 # objects or encoding names, and the first one is the external encoding, and the
16732 # second one is the internal encoding.
16733 # If the external encoding and the internal encoding is specified,
16734 # optional hash argument specify the conversion option.
16735 def set_encoding(ext_enc); IO.new; end
16736 ##
16737 # Returns +true+ if the underlying file descriptor of _ios_ will be
16738 # closed automatically at its finalization, otherwise +false+.
16739 def autoclose?; true || false; end
16740 ##
16741 # Sets auto-close flag.
16742 # 
16743 #    f = open("/dev/null")
16744 #    IO.for_fd(f.fileno)
16745 #    # ...
16746 #    f.gets # may cause IOError
16747 # 
16748 #    f = open("/dev/null")
16749 #    IO.for_fd(f.fileno).autoclose = true
16750 #    # ...
16751 #    f.gets # won't cause IOError
16752 def autoclose= bool; true || false; end
16753 end
16754 
16755 ##
16756 # A class that provides the functionality of Kernel#set_trace_func in a
16757 # nice Object-Oriented API.
16758 # 
16759 # == Example
16760 # 
16761 # We can use TracePoint to gather information specifically for exceptions:
16762 # 
16763 #      trace = TracePoint.new(:raise) do |tp|
16764 #          p [tp.lineno, tp.event, tp.raised_exception]
16765 #      end
16766 #      #=> #<TracePoint:0x007f786a452448>
16767 # 
16768 #      trace.enable
16769 #      #=> #<TracePoint:0x007f786a452448>
16770 # 
16771 #      0 / 0
16772 #      #=> [5, :raise, #<ZeroDivisionError: divided by 0>]
16773 # 
16774 # == Events
16775 # 
16776 # If you don't specify the type of events you want to listen for,
16777 # TracePoint will include all available events.
16778 # 
16779 # *Note* do not depend on current event set, as this list is subject to
16780 # change. Instead, it is recommended you specify the type of events you
16781 # want to use.
16782 # 
16783 # To filter what is traced, you can pass any of the following as +events+:
16784 # 
16785 # +:line+:: execute code on a new line
16786 # +:class+:: start a class or module definition
16787 # +:end+:: finish a class or module definition
16788 # +:call+:: call a Ruby method
16789 # +:return+:: return from a Ruby method
16790 # +:c_call+:: call a C-language routine
16791 # +:c_return+:: return from a C-language routine
16792 # +:raise+:: raise an exception
16793 # +:b_call+:: event hook at block entry
16794 # +:b_return+:: event hook at block ending
16795 # +:thread_begin+:: event hook at thread beginning
16796 # +:thread_end+:: event hook at thread ending
16797 class TracePoint < Object
16798 ##
16799 # Returns a new TracePoint object, not enabled by default.
16800 # 
16801 # Next, in order to activate the trace, you must use TracePoint.enable
16802 # 
16803 #      trace = TracePoint.new(:call) do |tp|
16804 #          p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
16805 #      end
16806 #      #=> #<TracePoint:0x007f17372cdb20>
16807 # 
16808 #      trace.enable
16809 #      #=> #<TracePoint:0x007f17372cdb20>
16810 # 
16811 #      puts "Hello, TracePoint!"
16812 #      # ...
16813 #      # [48, IRB::Notifier::AbstractNotifier, :printf, :call]
16814 #      # ...
16815 # 
16816 # When you want to deactivate the trace, you must use TracePoint.disable
16817 # 
16818 #      trace.disable
16819 # 
16820 # See TracePoint@Events for possible events and more information.
16821 # 
16822 # A block must be given, otherwise a ThreadError is raised.
16823 # 
16824 # If the trace method isn't included in the given events filter, a
16825 # RuntimeError is raised.
16826 # 
16827 #      TracePoint.trace(:line) do |tp|
16828 #          p tp.raised_exception
16829 #      end
16830 #      #=> RuntimeError: 'raised_exception' not supported by this event
16831 # 
16832 # If the trace method is called outside block, a RuntimeError is raised.
16833 # 
16834 #      TracePoint.trace(:line) do |tp|
16835 #        $tp = tp
16836 #      end
16837 #      $tp.line #=> access from outside (RuntimeError)
16838 # 
16839 # Access from other threads is also forbidden.
16840 def self.new(); end
16841 ##
16842 # A convenience method for TracePoint.new, that activates the trace
16843 # automatically.
16844 # 
16845 #     trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
16846 #     #=> #<TracePoint:0x007f786a452448>
16847 # 
16848 #     trace.enabled? #=> true
16849 def self.trace(); Object.new; end
16850 ##
16851 # Activates the trace
16852 # 
16853 # Return true if trace was enabled.
16854 # Return false if trace was disabled.
16855 # 
16856 #      trace.enabled?  #=> false
16857 #      trace.enable    #=> false (previous state)
16858 #                      #   trace is enabled
16859 #      trace.enabled?  #=> true
16860 #      trace.enable    #=> true (previous state)
16861 #                      #   trace is still enabled
16862 # 
16863 # If a block is given, the trace will only be enabled within the scope of the
16864 # block.
16865 # 
16866 #      trace.enabled?
16867 #      #=> false
16868 # 
16869 #      trace.enable do
16870 #          trace.enabled?
16871 #          # only enabled for this block
16872 #      end
16873 # 
16874 #      trace.enabled?
16875 #      #=> false
16876 # 
16877 # Note: You cannot access event hooks within the block.
16878 # 
16879 #      trace.enable { p tp.lineno }
16880 #      #=> RuntimeError: access from outside
16881 def enable; Object.new; end
16882 ##
16883 # Deactivates the trace
16884 # 
16885 # Return true if trace was enabled.
16886 # Return false if trace was disabled.
16887 # 
16888 #      trace.enabled?       #=> true
16889 #      trace.disable        #=> false (previous status)
16890 #      trace.enabled?       #=> false
16891 #      trace.disable        #=> false
16892 # 
16893 # If a block is given, the trace will only be disable within the scope of the
16894 # block.
16895 # 
16896 #      trace.enabled?
16897 #      #=> true
16898 # 
16899 #      trace.disable do
16900 #          trace.enabled?
16901 #          # only disabled for this block
16902 #      end
16903 # 
16904 #      trace.enabled?
16905 #      #=> true
16906 # 
16907 # Note: You cannot access event hooks within the block.
16908 # 
16909 #      trace.disable { p tp.lineno }
16910 #      #=> RuntimeError: access from outside
16911 def disable; Object.new; end
16912 ##
16913 # The current status of the trace
16914 def enabled?; true || false; end
16915 ##
16916 # Return a string containing a human-readable TracePoint
16917 # status.
16918 def inspect; ''; end
16919 end
16920 
16921 ##
16922 # Arrays are ordered, integer-indexed collections of any object.
16923 # 
16924 # Array indexing starts at 0, as in C or Java.  A negative index is assumed
16925 # to be relative to the end of the array---that is, an index of -1 indicates
16926 # the last element of the array, -2 is the next to last element in the
16927 # array, and so on.
16928 # 
16929 # == Creating Arrays
16930 # 
16931 # A new array can be created by using the literal constructor
16932 # <code>[]</code>.  Arrays can contain different types of objects.  For
16933 # example, the array below contains an Integer, a String and a Float:
16934 # 
16935 #    ary = [1, "two", 3.0] #=> [1, "two", 3.0]
16936 # 
16937 # An array can also be created by explicitly calling Array.new with zero, one
16938 # (the initial size of the Array) or two arguments (the initial size and a
16939 # default object).
16940 # 
16941 #    ary = Array.new    #=> []
16942 #    Array.new(3)       #=> [nil, nil, nil]
16943 #    Array.new(3, true) #=> [0, 0, 0]
16944 # 
16945 # Note that the second argument populates the array with references to the
16946 # same object.  Therefore, it is only recommended in cases when you need to
16947 # instantiate arrays with natively immutable objects such as Symbols,
16948 # numbers, true or false.
16949 # 
16950 # To create an array with separate objects a block can be passed instead.
16951 # This method is safe to use with mutable objects such as hashes, strings or
16952 # other arrays:
16953 # 
16954 #    Array.new(4) { Hash.new } #=> [{}, {}, {}, {}]
16955 # 
16956 # This is also a quick way to build up multi-dimensional arrays:
16957 # 
16958 #    empty_table = Array.new(3) { Array.new(3) }
16959 #    #=> [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]]
16960 # 
16961 # An array can also be created by using the Array() method, provided by
16962 # Kernel, which tries to call #to_ary, then #to_a on its argument.
16963 # 
16964 #     Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]]
16965 # 
16966 # == Example Usage
16967 # 
16968 # In addition to the methods it mixes in through the Enumerable module, the
16969 # Array class has proprietary methods for accessing, searching and otherwise
16970 # manipulating arrays.
16971 # 
16972 # Some of the more common ones are illustrated below.
16973 # 
16974 # == Accessing Elements
16975 # 
16976 # Elements in an array can be retrieved using the Array#[] method.  It can
16977 # take a single integer argument (a numeric index), a pair of arguments
16978 # (start and length) or a range.
16979 # 
16980 #    arr = [1, 2, 3, 4, 5, 6]
16981 #    arr[2]    #=> 3
16982 #    arr[100]  #=> nil
16983 #    arr[-3]   #=> 4
16984 #    arr[2, 3] #=> [3, 4, 5]
16985 #    arr[1..4] #=> [2, 3, 4, 5]
16986 # 
16987 # Another way to access a particular array element is by using the #at method
16988 # 
16989 #    arr.at(0) #=> 1
16990 # 
16991 # The #slice method works in an identical manner to Array#[].
16992 # 
16993 # To raise an error for indices outside of the array bounds or else to
16994 # provide a default value when that happens, you can use #fetch.
16995 # 
16996 #    arr = ['a', 'b', 'c', 'd', 'e', 'f']
16997 #    arr.fetch(100) #=> IndexError: index 100 outside of array bounds: -6...6
16998 #    arr.fetch(100, "oops") #=> "oops"
16999 # 
17000 # The special methods #first and #last will return the first and last
17001 # elements of an array, respectively.
17002 # 
17003 #    arr.first #=> 1
17004 #    arr.last  #=> 6
17005 # 
17006 # To return the first +n+ elements of an array, use #take
17007 # 
17008 #    arr.take(3) #=> [1, 2, 3]
17009 # 
17010 # #drop does the opposite of #take, by returning the elements after +n+
17011 # elements have been dropped:
17012 # 
17013 #    arr.drop(3) #=> [4, 5, 6]
17014 # 
17015 # == Obtaining Information about an Array
17016 # 
17017 # Arrays keep track of their own length at all times.  To query an array
17018 # about the number of elements it contains, use #length, #count or #size.
17019 # 
17020 #   browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
17021 #   browsers.length #=> 5
17022 #   browsers.count #=> 5
17023 # 
17024 # To check whether an array contains any elements at all
17025 # 
17026 #   browsers.empty? #=> false
17027 # 
17028 # To check whether a particular item is included in the array
17029 # 
17030 #   browsers.include?('Konqueror') #=> false
17031 # 
17032 # == Adding Items to Arrays
17033 # 
17034 # Items can be added to the end of an array by using either #push or #<<
17035 # 
17036 #   arr = [1, 2, 3, 4]
17037 #   arr.push(5) #=> [1, 2, 3, 4, 5]
17038 #   arr << 6    #=> [1, 2, 3, 4, 5, 6]
17039 # 
17040 # #unshift will add a new item to the beginning of an array.
17041 # 
17042 #    arr.unshift(0) #=> [0, 1, 2, 3, 4, 5, 6]
17043 # 
17044 # With #insert you can add a new element to an array at any position.
17045 # 
17046 #    arr.insert(3, 'apple')  #=> [0, 1, 2, 'apple', 3, 4, 5, 6]
17047 # 
17048 # Using the #insert method, you can also insert multiple values at once:
17049 # 
17050 #    arr.insert(3, 'orange', 'pear', 'grapefruit')
17051 #    #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6]
17052 # 
17053 # == Removing Items from an Array
17054 # 
17055 # The method #pop removes the last element in an array and returns it:
17056 # 
17057 #    arr =  [1, 2, 3, 4, 5, 6]
17058 #    arr.pop #=> 6
17059 #    arr #=> [1, 2, 3, 4, 5]
17060 # 
17061 # To retrieve and at the same time remove the first item, use #shift:
17062 # 
17063 #    arr.shift #=> 1
17064 #    arr #=> [2, 3, 4, 5]
17065 # 
17066 # To delete an element at a particular index:
17067 # 
17068 #    arr.delete_at(2) #=> 4
17069 #    arr #=> [2, 3, 5]
17070 # 
17071 # To delete a particular element anywhere in an array, use #delete:
17072 # 
17073 #    arr = [1, 2, 2, 3]
17074 #    arr.delete(2) #=> [1, 3]
17075 # 
17076 # A useful method if you need to remove +nil+ values from an array is
17077 # #compact:
17078 # 
17079 #    arr = ['foo', 0, nil, 'bar', 7, 'baz', nil]
17080 #    arr.compact  #=> ['foo', 0, 'bar', 7, 'baz']
17081 #    arr          #=> ['foo', 0, nil, 'bar', 7, 'baz', nil]
17082 #    arr.compact! #=> ['foo', 0, 'bar', 7, 'baz']
17083 #    arr          #=> ['foo', 0, 'bar', 7, 'baz']
17084 # 
17085 # Another common need is to remove duplicate elements from an array.
17086 # 
17087 # It has the non-destructive #uniq, and destructive method #uniq!
17088 # 
17089 #    arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
17090 #    arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
17091 # 
17092 # == Iterating over Arrays
17093 # 
17094 # Like all classes that include the Enumerable module, Array has an each
17095 # method, which defines what elements should be iterated over and how.  In
17096 # case of Array's #each, all elements in the Array instance are yielded to
17097 # the supplied block in sequence.
17098 # 
17099 # Note that this operation leaves the array unchanged.
17100 # 
17101 #    arr = [1, 2, 3, 4, 5]
17102 #    arr.each { |a| print a -= 10, " " }
17103 #    # prints: -9 -8 -7 -6 -5
17104 #    #=> [1, 2, 3, 4, 5]
17105 # 
17106 # Another sometimes useful iterator is #reverse_each which will iterate over
17107 # the elements in the array in reverse order.
17108 # 
17109 #    words = %w[rats live on no evil star]
17110 #    str = ""
17111 #    words.reverse_each { |word| str += "#{word.reverse} " }
17112 #    str #=> "rats live on no evil star "
17113 # 
17114 # The #map method can be used to create a new array based on the original
17115 # array, but with the values modified by the supplied block:
17116 # 
17117 #    arr.map { |a| 2*a }   #=> [2, 4, 6, 8, 10]
17118 #    arr                   #=> [1, 2, 3, 4, 5]
17119 #    arr.map! { |a| a**2 } #=> [1, 4, 9, 16, 25]
17120 #    arr                   #=> [1, 4, 9, 16, 25]
17121 # 
17122 # == Selecting Items from an Array
17123 # 
17124 # Elements can be selected from an array according to criteria defined in a
17125 # block.  The selection can happen in a destructive or a non-destructive
17126 # manner.  While the destructive operations will modify the array they were
17127 # called on, the non-destructive methods usually return a new array with the
17128 # selected elements, but leave the original array unchanged.
17129 # 
17130 # === Non-destructive Selection
17131 # 
17132 #    arr = [1, 2, 3, 4, 5, 6]
17133 #    arr.select { |a| a > 3 }     #=> [4, 5, 6]
17134 #    arr.reject { |a| a < 3 }     #=> [4, 5, 6]
17135 #    arr.drop_while { |a| a < 4 } #=> [4, 5, 6]
17136 #    arr                          #=> [1, 2, 3, 4, 5, 6]
17137 # 
17138 # === Destructive Selection
17139 # 
17140 # #select! and #reject! are the corresponding destructive methods to #select
17141 # and #reject
17142 # 
17143 # Similar to #select vs. #reject, #delete_if and #keep_if have the exact
17144 # opposite result when supplied with the same block:
17145 # 
17146 #    arr.delete_if { |a| a < 4 } #=> [4, 5, 6]
17147 #    arr                         #=> [4, 5, 6]
17148 # 
17149 #    arr = [1, 2, 3, 4, 5, 6]
17150 #    arr.keep_if { |a| a < 4 } #=> [1, 2, 3]
17151 #    arr                       #=> [1, 2, 3]
17152 class Array < Object
17153 include Enumerable
17154 ##
17155 # Tries to convert +obj+ into an array, using +to_ary+ method.  Returns the
17156 # converted array or +nil+ if +obj+ cannot be converted for any reason.
17157 # This method can be used to check if an argument is an array.
17158 # 
17159 #    Array.try_convert([1])   #=> [1]
17160 #    Array.try_convert("1")   #=> nil
17161 # 
17162 #    if tmp = Array.try_convert(arg)
17163 #      # the argument is an array
17164 #    elsif tmp = String.try_convert(arg)
17165 #      # the argument is a string
17166 #    end
17167 def self.try_convert(obj); [] || nil; end
17168 ##
17169 # Returns a new array.
17170 # 
17171 # In the first form, if no arguments are sent, the new array will be empty.
17172 # When a +size+ and an optional +obj+ are sent, an array is created with
17173 # +size+ copies of +obj+.  Take notice that all elements will reference the
17174 # same object +obj+.
17175 # 
17176 # The second form creates a copy of the array passed as a parameter (the
17177 # array is generated by calling to_ary on the parameter).
17178 # 
17179 #   first_array = ["Matz", "Guido"]
17180 # 
17181 #   second_array = Array.new(first_array) #=> ["Matz", "Guido"]
17182 # 
17183 #   first_array.equal? second_array       #=> false
17184 # 
17185 # In the last form, an array of the given size is created.  Each element in
17186 # this array is created by passing the element's index to the given block
17187 # and storing the return value.
17188 # 
17189 #   Array.new(3){ |index| index ** 2 }
17190 #   # => [0, 1, 4]
17191 # 
17192 # == Common gotchas
17193 # 
17194 # When sending the second parameter, the same object will be used as the
17195 # value for all the array elements:
17196 # 
17197 #    a = Array.new(2, Hash.new)
17198 #    # => [{}, {}]
17199 # 
17200 #    a[0]['cat'] = 'feline'
17201 #    a # => [{"cat"=>"feline"}, {"cat"=>"feline"}]
17202 # 
17203 #    a[1]['cat'] = 'Felix'
17204 #    a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}]
17205 # 
17206 # Since all the Array elements store the same hash, changes to one of them
17207 # will affect them all.
17208 # 
17209 # If multiple copies are what you want, you should use the block
17210 # version which uses the result of that block each time an element
17211 # of the array needs to be initialized:
17212 # 
17213 #    a = Array.new(2) { Hash.new }
17214 #    a[0]['cat'] = 'feline'
17215 #    a # => [{"cat"=>"feline"}, {}]
17216 def self.new(size=0, obj=null); end
17217 ##
17218 # Replaces the contents of +self+ with the contents of +other_ary+,
17219 # truncating or expanding if necessary.
17220 # 
17221 #    a = [ "a", "b", "c", "d", "e" ]
17222 #    a.replace([ "x", "y", "z" ])   #=> ["x", "y", "z"]
17223 #    a                              #=> ["x", "y", "z"]
17224 def replace(other_ary); []; end
17225 ##
17226 # Creates a string representation of +self+.
17227 # 
17228 #    [ "a", "b", "c" ].to_s     #=> "[\"a\", \"b\", \"c\"]"
17229 def inspect; ''; end
17230 ##
17231 # Creates a string representation of +self+.
17232 # 
17233 #    [ "a", "b", "c" ].to_s     #=> "[\"a\", \"b\", \"c\"]"
17234 def to_s; ''; end
17235 ##
17236 # Returns +self+.
17237 # 
17238 # If called on a subclass of Array, converts the receiver to an Array object.
17239 def to_a; []; end
17240 ##
17241 # Returns +self+.
17242 def to_ary; []; end
17243 ##
17244 # Return +true+ if this array is frozen (or temporarily frozen
17245 # while being sorted). See also Object#frozen?
17246 def frozen?; true || false; end
17247 ##
17248 # Equality --- Two arrays are equal if they contain the same number of
17249 # elements and if each element is equal to (according to Object#==) the
17250 # corresponding element in +other_ary+.
17251 # 
17252 #    [ "a", "c" ]    == [ "a", "c", 7 ]     #=> false
17253 #    [ "a", "c", 7 ] == [ "a", "c", 7 ]     #=> true
17254 #    [ "a", "c", 7 ] == [ "a", "d", "f" ]   #=> false
17255 def ==; true || false; end
17256 ##
17257 # Returns +true+ if +self+ and +other+ are the same object,
17258 # or are both arrays with the same content.
17259 def eql?(other); true || false; end
17260 ##
17261 # Compute a hash-code for this array.
17262 # 
17263 # Two arrays with the same content will have the same hash code (and will
17264 # compare using #eql?).
17265 def hash; 0; end
17266 ##
17267 # Element Reference --- Returns the element at +index+, or returns a
17268 # subarray starting at the +start+ index and continuing for +length+
17269 # elements, or returns a subarray specified by +range+ of indices.
17270 # 
17271 # Negative indices count backward from the end of the array (-1 is the last
17272 # element).  For +start+ and +range+ cases the starting index is just before
17273 # an element.  Additionally, an empty array is returned when the starting
17274 # index for an element range is at the end of the array.
17275 # 
17276 # Returns +nil+ if the index (or starting index) are out of range.
17277 # 
17278 #    a = [ "a", "b", "c", "d", "e" ]
17279 #    a[2] +  a[0] + a[1]    #=> "cab"
17280 #    a[6]                   #=> nil
17281 #    a[1, 2]                #=> [ "b", "c" ]
17282 #    a[1..3]                #=> [ "b", "c", "d" ]
17283 #    a[4..7]                #=> [ "e" ]
17284 #    a[6..10]               #=> nil
17285 #    a[-3, 3]               #=> [ "c", "d", "e" ]
17286 #    # special cases
17287 #    a[5]                   #=> nil
17288 #    a[6, 1]                #=> nil
17289 #    a[5, 1]                #=> []
17290 #    a[5..10]               #=> []
17291 def []; [] || nil; end
17292 ##
17293 # Element Reference --- Returns the element at +index+, or returns a
17294 # subarray starting at the +start+ index and continuing for +length+
17295 # elements, or returns a subarray specified by +range+ of indices.
17296 # 
17297 # Negative indices count backward from the end of the array (-1 is the last
17298 # element).  For +start+ and +range+ cases the starting index is just before
17299 # an element.  Additionally, an empty array is returned when the starting
17300 # index for an element range is at the end of the array.
17301 # 
17302 # Returns +nil+ if the index (or starting index) are out of range.
17303 # 
17304 #    a = [ "a", "b", "c", "d", "e" ]
17305 #    a[2] +  a[0] + a[1]    #=> "cab"
17306 #    a[6]                   #=> nil
17307 #    a[1, 2]                #=> [ "b", "c" ]
17308 #    a[1..3]                #=> [ "b", "c", "d" ]
17309 #    a[4..7]                #=> [ "e" ]
17310 #    a[6..10]               #=> nil
17311 #    a[-3, 3]               #=> [ "c", "d", "e" ]
17312 #    # special cases
17313 #    a[5]                   #=> nil
17314 #    a[6, 1]                #=> nil
17315 #    a[5, 1]                #=> []
17316 #    a[5..10]               #=> []
17317 def slice(index); [] || nil; end
17318 ##
17319 # Element Assignment --- Sets the element at +index+, or replaces a subarray
17320 # from the +start+ index for +length+ elements, or replaces a subarray
17321 # specified by the +range+ of indices.
17322 # 
17323 # If indices are greater than the current capacity of the array, the array
17324 # grows automatically.  Elements are inserted into the array at +start+ if
17325 # +length+ is zero.
17326 # 
17327 # Negative indices will count backward from the end of the array.  For
17328 # +start+ and +range+ cases the starting index is just before an element.
17329 # 
17330 # An IndexError is raised if a negative index points past the beginning of
17331 # the array.
17332 # 
17333 # See also Array#push, and Array#unshift.
17334 # 
17335 #    a = Array.new
17336 #    a[4] = "4";                 #=> [nil, nil, nil, nil, "4"]
17337 #    a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"]
17338 #    a[1..2] = [ 1, 2 ]          #=> ["a", 1, 2, nil, "4"]
17339 #    a[0, 2] = "?"               #=> ["?", 2, nil, "4"]
17340 #    a[0..2] = "A"               #=> ["A", "4"]
17341 #    a[-1]   = "Z"               #=> ["A", "Z"]
17342 #    a[1..-1] = nil              #=> ["A", nil]
17343 #    a[1..-1] = []               #=> ["A"]
17344 #    a[0, 0] = [ 1, 2 ]          #=> [1, 2, "A"]
17345 #    a[3, 0] = "B"               #=> [1, 2, "A", "B"]
17346 def []=; [] || nil; end
17347 ##
17348 # Returns the element at +index+. A negative index counts from the end of
17349 # +self+. Returns +nil+ if the index is out of range. See also
17350 # Array#[].
17351 # 
17352 #    a = [ "a", "b", "c", "d", "e" ]
17353 #    a.at(0)     #=> "a"
17354 #    a.at(-1)    #=> "e"
17355 def at(index); Object.new || nil; end
17356 ##
17357 # Tries to return the element at position +index+, but throws an IndexError
17358 # exception if the referenced +index+ lies outside of the array bounds.  This
17359 # error can be prevented by supplying a second argument, which will act as a
17360 # +default+ value.
17361 # 
17362 # Alternatively, if a block is given it will only be executed when an
17363 # invalid +index+ is referenced.  Negative values of +index+ count from the
17364 # end of the array.
17365 # 
17366 #    a = [ 11, 22, 33, 44 ]
17367 #    a.fetch(1)               #=> 22
17368 #    a.fetch(-1)              #=> 44
17369 #    a.fetch(4, 'cat')        #=> "cat"
17370 #    a.fetch(100) { |i| puts "#{i} is out of bounds" }
17371 #                             #=> "100 is out of bounds"
17372 def fetch(index); Object.new; end
17373 ##
17374 # Returns the first element, or the first +n+ elements, of the array.
17375 # If the array is empty, the first form returns +nil+, and the
17376 # second form returns an empty array. See also Array#last for
17377 # the opposite effect.
17378 # 
17379 #    a = [ "q", "r", "s", "t" ]
17380 #    a.first     #=> "q"
17381 #    a.first(2)  #=> ["q", "r"]
17382 def first; []; end
17383 ##
17384 # Returns the last element(s) of +self+. If the array is empty,
17385 # the first form returns +nil+.
17386 # 
17387 # See also Array#first for the opposite effect.
17388 # 
17389 #    a = [ "w", "x", "y", "z" ]
17390 #    a.last     #=> "z"
17391 #    a.last(2)  #=> ["y", "z"]
17392 def last; []; end
17393 ##
17394 # Appends the elements of +other_ary+ to +self+.
17395 # 
17396 #    [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
17397 #    a = [ 1, 2, 3 ]
17398 #    a.concat( [ 4, 5 ] )
17399 #    a                                 #=> [ 1, 2, 3, 4, 5 ]
17400 # 
17401 # See also Array#+.
17402 def concat(other_ary); []; end
17403 ##
17404 # Append---Pushes the given object on to the end of this array. This
17405 # expression returns the array itself, so several appends
17406 # may be chained together.
17407 # 
17408 #    [ 1, 2 ] << "c" << "d" << [ 3, 4 ]
17409 #            #=>  [ 1, 2, "c", "d", [ 3, 4 ] ]
17410 def <<; []; end
17411 ##
17412 # Append --- Pushes the given object(s) on to the end of this array. This
17413 # expression returns the array itself, so several appends
17414 # may be chained together. See also Array#pop for the opposite
17415 # effect.
17416 # 
17417 #    a = [ "a", "b", "c" ]
17418 #    a.push("d", "e", "f")
17419 #            #=> ["a", "b", "c", "d", "e", "f"]
17420 #    [1, 2, 3,].push(4).push(5)
17421 #            #=> [1, 2, 3, 4, 5]
17422 def push(); []; end
17423 ##
17424 # Removes the last element from +self+ and returns it, or
17425 # +nil+ if the array is empty.
17426 # 
17427 # If a number +n+ is given, returns an array of the last +n+ elements
17428 # (or less) just like <code>array.slice!(-n, n)</code> does. See also
17429 # Array#push for the opposite effect.
17430 # 
17431 #    a = [ "a", "b", "c", "d" ]
17432 #    a.pop     #=> "d"
17433 #    a.pop(2)  #=> ["b", "c"]
17434 #    a         #=> ["a"]
17435 def pop; []; end
17436 ##
17437 # Removes the first element of +self+ and returns it (shifting all
17438 # other elements down by one). Returns +nil+ if the array
17439 # is empty.
17440 # 
17441 # If a number +n+ is given, returns an array of the first +n+ elements
17442 # (or less) just like <code>array.slice!(0, n)</code> does. With +ary+
17443 # containing only the remainder elements, not including what was shifted to
17444 # +new_ary+. See also Array#unshift for the opposite effect.
17445 # 
17446 #    args = [ "-m", "-q", "filename" ]
17447 #    args.shift     #=> "-m"
17448 #    args           #=> ["-q", "filename"]
17449 # 
17450 #    args = [ "-m", "-q", "filename" ]
17451 #    args.shift(2)  #=> ["-m", "-q"]
17452 #    args           #=> ["filename"]
17453 def shift; []; end
17454 ##
17455 # Prepends objects to the front of +self+, moving other elements upwards.
17456 # See also Array#shift for the opposite effect.
17457 # 
17458 #    a = [ "b", "c", "d" ]
17459 #    a.unshift("a")   #=> ["a", "b", "c", "d"]
17460 #    a.unshift(1, 2)  #=> [ 1, 2, "a", "b", "c", "d"]
17461 def unshift(); []; end
17462 ##
17463 # Inserts the given values before the element with the given +index+.
17464 # 
17465 # Negative indices count backwards from the end of the array, where +-1+ is
17466 # the last element.
17467 # 
17468 #    a = %w{ a b c d }
17469 #    a.insert(2, 99)         #=> ["a", "b", 99, "c", "d"]
17470 #    a.insert(-2, 1, 2, 3)   #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
17471 def insert(); []; end
17472 ##
17473 # Calls the given block once for each element in +self+, passing that element
17474 # as a parameter.
17475 # 
17476 # An Enumerator is returned if no block is given.
17477 # 
17478 #    a = [ "a", "b", "c" ]
17479 #    a.each {|x| print x, " -- " }
17480 # 
17481 # produces:
17482 # 
17483 #    a -- b -- c --
17484 def each(&block); Enumerator.new; end
17485 ##
17486 # Same as Array#each, but passes the +index+ of the element instead of the
17487 # element itself.
17488 # 
17489 # An Enumerator is returned if no block is given.
17490 # 
17491 #    a = [ "a", "b", "c" ]
17492 #    a.each_index {|x| print x, " -- " }
17493 # 
17494 # produces:
17495 # 
17496 #    0 -- 1 -- 2 --
17497 def each_index(&block); Enumerator.new; end
17498 ##
17499 # Same as Array#each, but traverses +self+ in reverse order.
17500 # 
17501 #    a = [ "a", "b", "c" ]
17502 #    a.reverse_each {|x| print x, " " }
17503 # 
17504 # produces:
17505 # 
17506 #    c b a
17507 def reverse_each(&block); Enumerator.new; end
17508 ##
17509 # Returns the number of elements in +self+. May be zero.
17510 # 
17511 #    [ 1, 2, 3, 4, 5 ].length   #=> 5
17512 #    [].length                  #=> 0
17513 def length; 0; end
17514 ##
17515 # Returns +true+ if +self+ contains no elements.
17516 # 
17517 #    [].empty?   #=> true
17518 def empty?; true || false; end
17519 ##
17520 # Returns the _index_ of the first object in +ary+ such that the object is
17521 # <code>==</code> to +obj+.
17522 # 
17523 # If a block is given instead of an argument, returns the _index_ of the
17524 # first object for which the block returns +true+.  Returns +nil+ if no
17525 # match is found.
17526 # 
17527 # See also Array#rindex.
17528 # 
17529 # An Enumerator is returned if neither a block nor argument is given.
17530 # 
17531 #    a = [ "a", "b", "c" ]
17532 #    a.index("b")              #=> 1
17533 #    a.index("z")              #=> nil
17534 #    a.index { |x| x == "b" }  #=> 1
17535 # 
17536 # This is an alias of Array#find_index.
17537 def index(obj); Enumerator.new; end
17538 ##
17539 # Returns the _index_ of the last object in +self+ <code>==</code> to +obj+.
17540 # 
17541 # If a block is given instead of an argument, returns the _index_ of the
17542 # first object for which the block returns +true+, starting from the last
17543 # object.
17544 # 
17545 # Returns +nil+ if no match is found.
17546 # 
17547 # See also Array#index.
17548 # 
17549 # If neither block nor argument is given, an Enumerator is returned instead.
17550 # 
17551 #    a = [ "a", "b", "b", "b", "c" ]
17552 #    a.rindex("b")             #=> 3
17553 #    a.rindex("z")             #=> nil
17554 #    a.rindex { |x| x == "b" } #=> 3
17555 def rindex(obj); Enumerator.new; end
17556 ##
17557 # Returns a string created by converting each element of the array to
17558 # a string, separated by the given +separator+.
17559 # If the +separator+ is +nil+, it uses current $,.
17560 # If both the +separator+ and $, are nil, it uses empty string.
17561 # 
17562 #    [ "a", "b", "c" ].join        #=> "abc"
17563 #    [ "a", "b", "c" ].join("-")   #=> "a-b-c"
17564 def join(separator=$,); ''; end
17565 ##
17566 # Returns a new array containing +self+'s elements in reverse order.
17567 # 
17568 #    [ "a", "b", "c" ].reverse   #=> ["c", "b", "a"]
17569 #    [ 1 ].reverse               #=> [1]
17570 def reverse; []; end
17571 ##
17572 # Reverses +self+ in place.
17573 # 
17574 #    a = [ "a", "b", "c" ]
17575 #    a.reverse!       #=> ["c", "b", "a"]
17576 #    a                #=> ["c", "b", "a"]
17577 def reverse!; []; end
17578 ##
17579 # Returns a new array by rotating +self+ so that the element at +count+ is
17580 # the first element of the new array.
17581 # 
17582 # If +count+ is negative then it rotates in the opposite direction, starting
17583 # from the end of +self+ where +-1+ is the last element.
17584 # 
17585 #    a = [ "a", "b", "c", "d" ]
17586 #    a.rotate         #=> ["b", "c", "d", "a"]
17587 #    a                #=> ["a", "b", "c", "d"]
17588 #    a.rotate(2)      #=> ["c", "d", "a", "b"]
17589 #    a.rotate(-3)     #=> ["b", "c", "d", "a"]
17590 def rotate(count=1); []; end
17591 ##
17592 # Rotates +self+ in place so that the element at +count+ comes first, and
17593 # returns +self+.
17594 # 
17595 # If +count+ is negative then it rotates in the opposite direction, starting
17596 # from the end of the array where +-1+ is the last element.
17597 # 
17598 #    a = [ "a", "b", "c", "d" ]
17599 #    a.rotate!        #=> ["b", "c", "d", "a"]
17600 #    a                #=> ["b", "c", "d", "a"]
17601 #    a.rotate!(2)     #=> ["d", "a", "b", "c"]
17602 #    a.rotate!(-3)    #=> ["a", "b", "c", "d"]
17603 def rotate!(count=1); []; end
17604 ##
17605 # Returns a new array created by sorting +self+.
17606 # 
17607 # Comparisons for the sort will be done using the <code><=></code> operator
17608 # or using an optional code block.
17609 # 
17610 # The block must implement a comparison between +a+ and +b+, and return
17611 # +-1+, when +a+ follows +b+, +0+ when +a+ and +b+ are equivalent, or ++1+
17612 # if +b+ follows +a+.
17613 # 
17614 # See also Enumerable#sort_by.
17615 # 
17616 #    a = [ "d", "a", "e", "c", "b" ]
17617 #    a.sort                    #=> ["a", "b", "c", "d", "e"]
17618 #    a.sort { |x,y| y <=> x }  #=> ["e", "d", "c", "b", "a"]
17619 def sort; []; end
17620 ##
17621 # Sorts +self+ in place.
17622 # 
17623 # Comparisons for the sort will be done using the <code><=></code> operator
17624 # or using an optional code block.
17625 # 
17626 # The block must implement a comparison between +a+ and +b+, and return
17627 # +-1+, when +a+ follows +b+, +0+ when +a+ and +b+ are equivalent, or ++1+
17628 # if +b+ follows +a+.
17629 # 
17630 # See also Enumerable#sort_by.
17631 # 
17632 #    a = [ "d", "a", "e", "c", "b" ]
17633 #    a.sort!                    #=> ["a", "b", "c", "d", "e"]
17634 #    a.sort! { |x,y| y <=> x }  #=> ["e", "d", "c", "b", "a"]
17635 def sort!; []; end
17636 ##
17637 # Sorts +self+ in place using a set of keys generated by mapping the
17638 # values in +self+ through the given block.
17639 # 
17640 # If no block is given, an Enumerator is returned instead.
17641 def sort_by!(&block); Enumerator.new; end
17642 ##
17643 # Invokes the given block once for each element of +self+.
17644 # 
17645 # Creates a new array containing the values returned by the block.
17646 # 
17647 # See also Enumerable#collect.
17648 # 
17649 # If no block is given, an Enumerator is returned instead.
17650 # 
17651 #    a = [ "a", "b", "c", "d" ]
17652 #    a.map { |x| x + "!" }   #=> ["a!", "b!", "c!", "d!"]
17653 #    a                       #=> ["a", "b", "c", "d"]
17654 def collect(&block); Enumerator.new; end
17655 ##
17656 # Invokes the given block once for each element of +self+.
17657 # 
17658 # Creates a new array containing the values returned by the block.
17659 # 
17660 # See also Enumerable#collect.
17661 # 
17662 # If no block is given, an Enumerator is returned instead.
17663 # 
17664 #    a = [ "a", "b", "c", "d" ]
17665 #    a.map { |x| x + "!" }   #=> ["a!", "b!", "c!", "d!"]
17666 #    a                       #=> ["a", "b", "c", "d"]
17667 def map(&block); Enumerator.new; end
17668 ##
17669 # Invokes the given block once for each element of +self+, replacing the
17670 # element with the value returned by the block.
17671 # 
17672 # See also Enumerable#collect.
17673 # 
17674 # If no block is given, an Enumerator is returned instead.
17675 # 
17676 #    a = [ "a", "b", "c", "d" ]
17677 #    a.map! {|x| x + "!" }
17678 #    a #=>  [ "a!", "b!", "c!", "d!" ]
17679 def collect!(&block); Enumerator.new; end
17680 ##
17681 # Invokes the given block once for each element of +self+, replacing the
17682 # element with the value returned by the block.
17683 # 
17684 # See also Enumerable#collect.
17685 # 
17686 # If no block is given, an Enumerator is returned instead.
17687 # 
17688 #    a = [ "a", "b", "c", "d" ]
17689 #    a.map! {|x| x + "!" }
17690 #    a #=>  [ "a!", "b!", "c!", "d!" ]
17691 def map!(&block); Enumerator.new; end
17692 ##
17693 # Returns a new array containing all elements of +ary+
17694 # for which the given +block+ returns a true value.
17695 # 
17696 # If no block is given, an Enumerator is returned instead.
17697 # 
17698 #    [1,2,3,4,5].select { |num|  num.even?  }   #=> [2, 4]
17699 # 
17700 #    a = %w{ a b c d e f }
17701 #    a.select { |v| v =~ /[aeiou]/ }  #=> ["a", "e"]
17702 # 
17703 # See also Enumerable#select.
17704 def select(&block); Enumerator.new; end
17705 ##
17706 # Invokes the given block passing in successive elements from +self+,
17707 # deleting elements for which the block returns a +false+ value.
17708 # 
17709 # If changes were made, it will return +self+, otherwise it returns +nil+.
17710 # 
17711 # See also Array#keep_if
17712 # 
17713 # If no block is given, an Enumerator is returned instead.
17714 def select!(&block); Enumerator.new; end
17715 ##
17716 # Deletes every element of +self+ for which the given block evaluates to
17717 # +false+.
17718 # 
17719 # See also Array#select!
17720 # 
17721 # If no block is given, an Enumerator is returned instead.
17722 # 
17723 #    a = %w{ a b c d e f }
17724 #    a.keep_if { |v| v =~ /[aeiou]/ }  #=> ["a", "e"]
17725 def keep_if(&block); Enumerator.new; end
17726 ##
17727 # Returns an array containing the elements in +self+ corresponding to the
17728 # given +selector+(s).
17729 # 
17730 # The selectors may be either integer indices or ranges.
17731 # 
17732 # See also Array#select.
17733 # 
17734 #    a = %w{ a b c d e f }
17735 #    a.values_at(1, 3, 5)          # => ["b", "d", "f"]
17736 #    a.values_at(1, 3, 5, 7)       # => ["b", "d", "f", nil]
17737 #    a.values_at(-1, -2, -2, -7)   # => ["f", "e", "e", nil]
17738 #    a.values_at(4..6, 3...6)      # => ["e", "f", nil, "d", "e", "f"]
17739 def values_at(); []; end
17740 ##
17741 # Deletes all items from +self+ that are equal to +obj+.
17742 # 
17743 # Returns the last deleted item, or +nil+ if no matching item is found.
17744 # 
17745 # If the optional code block is given, the result of the block is returned if
17746 # the item is not found.  (To remove +nil+ elements and get an informative
17747 # return value, use Array#compact!)
17748 # 
17749 #    a = [ "a", "b", "b", "b", "c" ]
17750 #    a.delete("b")                   #=> "b"
17751 #    a                               #=> ["a", "c"]
17752 #    a.delete("z")                   #=> nil
17753 #    a.delete("z") { "not found" }   #=> "not found"
17754 def delete(obj); Object.new || nil; end
17755 ##
17756 # Deletes the element at the specified +index+, returning that element, or
17757 # +nil+ if the +index+ is out of range.
17758 # 
17759 # See also Array#slice!
17760 # 
17761 #    a = ["ant", "bat", "cat", "dog"]
17762 #    a.delete_at(2)    #=> "cat"
17763 #    a                 #=> ["ant", "bat", "dog"]
17764 #    a.delete_at(99)   #=> nil
17765 def delete_at(index); Object.new || nil; end
17766 ##
17767 # Deletes every element of +self+ for which block evaluates to +true+.
17768 # 
17769 # The array is changed instantly every time the block is called, not after
17770 # the iteration is over.
17771 # 
17772 # See also Array#reject!
17773 # 
17774 # If no block is given, an Enumerator is returned instead.
17775 # 
17776 #    a = [ "a", "b", "c" ]
17777 #    a.delete_if {|x| x >= "b" }   #=> ["a"]
17778 def delete_if(&block); Enumerator.new; end
17779 ##
17780 # Returns a new array containing the items in +self+ for which the given
17781 # block is not +true+.
17782 # 
17783 # See also Array#delete_if
17784 # 
17785 # If no block is given, an Enumerator is returned instead.
17786 def reject(&block); Enumerator.new; end
17787 ##
17788 # Equivalent to Array#delete_if, deleting elements from +self+ for which the
17789 # block evaluates to +true+, but returns +nil+ if no changes were made.
17790 # 
17791 # The array is changed instantly every time the block is called, not after
17792 # the iteration is over.
17793 # 
17794 # See also Enumerable#reject and Array#delete_if.
17795 # 
17796 # If no block is given, an Enumerator is returned instead.
17797 def reject!(&block); Enumerator.new; end
17798 ##
17799 # Converts any arguments to arrays, then merges elements of +self+ with
17800 # corresponding elements from each argument.
17801 # 
17802 # This generates a sequence of <code>ary.size</code> _n_-element arrays,
17803 # where _n_ is one more that the count of arguments.
17804 # 
17805 # If the size of any argument is less than the size of the initial array,
17806 # +nil+ values are supplied.
17807 # 
17808 # If a block is given, it is invoked for each output +array+, otherwise an
17809 # array of arrays is returned.
17810 # 
17811 #    a = [ 4, 5, 6 ]
17812 #    b = [ 7, 8, 9 ]
17813 #    [1, 2, 3].zip(a, b)   #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
17814 #    [1, 2].zip(a, b)      #=> [[1, 4, 7], [2, 5, 8]]
17815 #    a.zip([1, 2], [8])    #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
17816 def zip(); end
17817 ##
17818 # Assumes that +self+ is an array of arrays and transposes the rows and
17819 # columns.
17820 # 
17821 #    a = [[1,2], [3,4], [5,6]]
17822 #    a.transpose   #=> [[1, 3, 5], [2, 4, 6]]
17823 # 
17824 # If the length of the subarrays don't match, an IndexError is raised.
17825 def transpose; []; end
17826 ##
17827 # Removes all elements from +self+.
17828 # 
17829 #    a = [ "a", "b", "c", "d", "e" ]
17830 #    a.clear    #=> [ ]
17831 def clear; []; end
17832 ##
17833 # The first three forms set the selected elements of +self+ (which
17834 # may be the entire array) to +obj+.
17835 # 
17836 # A +start+ of +nil+ is equivalent to zero.
17837 # 
17838 # A +length+ of +nil+ is equivalent to the length of the array.
17839 # 
17840 # The last three forms fill the array with the value of the given block,
17841 # which is passed the absolute index of each element to be filled.
17842 # 
17843 # Negative values of +start+ count from the end of the array, where +-1+ is
17844 # the last element.
17845 # 
17846 #    a = [ "a", "b", "c", "d" ]
17847 #    a.fill("x")              #=> ["x", "x", "x", "x"]
17848 #    a.fill("z", 2, 2)        #=> ["x", "x", "z", "z"]
17849 #    a.fill("y", 0..1)        #=> ["y", "y", "z", "z"]
17850 #    a.fill { |i| i*i }       #=> [0, 1, 4, 9]
17851 #    a.fill(-2) { |i| i*i*i } #=> [0, 1, 8, 27]
17852 def fill(obj); []; end
17853 ##
17854 # Returns +true+ if the given +object+ is present in +self+ (that is, if any
17855 # object <code>==</code> +object+), otherwise returns +false+.
17856 # 
17857 #    a = [ "a", "b", "c" ]
17858 #    a.include?("b")   #=> true
17859 #    a.include?("z")   #=> false
17860 def include?(object); true || false; end
17861 ##
17862 # Comparison --- Returns an integer (+-1+, +0+, or <code>+1</code>) if this
17863 # array is less than, equal to, or greater than +other_ary+.
17864 # 
17865 # +nil+ is returned if the two values are incomparable.
17866 # 
17867 # Each object in each array is compared (using the <=> operator).
17868 # 
17869 # Arrays are compared in an "element-wise" manner; the first two elements
17870 # that are not equal will determine the return value for the whole
17871 # comparison.
17872 # 
17873 # If all the values are equal, then the return is based on a comparison of
17874 # the array lengths. Thus, two arrays are "equal" according to Array#<=> if,
17875 # and only if, they have the same length and the value of each element is
17876 # equal to the value of the corresponding element in the other array.
17877 # 
17878 #    [ "a", "a", "c" ]    <=> [ "a", "b", "c" ]   #=> -1
17879 #    [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ]            #=> +1
17880 def <=>; 1 || nil; end
17881 ##
17882 # Deletes the element(s) given by an +index+ (optionally up to +length+
17883 # elements) or by a +range+.
17884 # 
17885 # Returns the deleted object (or objects), or +nil+ if the +index+ is out of
17886 # range.
17887 # 
17888 #    a = [ "a", "b", "c" ]
17889 #    a.slice!(1)     #=> "b"
17890 #    a               #=> ["a", "c"]
17891 #    a.slice!(-1)    #=> "c"
17892 #    a               #=> ["a"]
17893 #    a.slice!(100)   #=> nil
17894 #    a               #=> ["a"]
17895 def slice!(index); [] || nil; end
17896 ##
17897 # Searches through an array whose elements are also arrays comparing +obj+
17898 # with the first element of each contained array using <code>obj.==</code>.
17899 # 
17900 # Returns the first contained array that matches (that is, the first
17901 # associated array), or +nil+ if no match is found.
17902 # 
17903 # See also Array#rassoc
17904 # 
17905 #    s1 = [ "colors", "red", "blue", "green" ]
17906 #    s2 = [ "letters", "a", "b", "c" ]
17907 #    s3 = "foo"
17908 #    a  = [ s1, s2, s3 ]
17909 #    a.assoc("letters")  #=> [ "letters", "a", "b", "c" ]
17910 #    a.assoc("foo")      #=> nil
17911 def assoc(obj); []; end
17912 ##
17913 # Searches through the array whose elements are also arrays.
17914 # 
17915 # Compares +obj+ with the second element of each contained array using
17916 # <code>obj.==</code>.
17917 # 
17918 # Returns the first contained array that matches +obj+.
17919 # 
17920 # See also Array#assoc.
17921 # 
17922 #    a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ]
17923 #    a.rassoc("two")    #=> [2, "two"]
17924 #    a.rassoc("four")   #=> nil
17925 def rassoc(obj); [] || nil; end
17926 ##
17927 # Concatenation --- Returns a new array built by concatenating the
17928 # two arrays together to produce a third array.
17929 # 
17930 #    [ 1, 2, 3 ] + [ 4, 5 ]    #=> [ 1, 2, 3, 4, 5 ]
17931 #    a = [ "a", "b", "c" ]
17932 #    a + [ "d", "e", "f" ]
17933 #    a                         #=> [ "a", "b", "c", "d", "e", "f" ]
17934 # 
17935 # See also Array#concat.
17936 def +; []; end
17937 ##
17938 # Repetition --- With a String argument, equivalent to
17939 # <code>ary.join(str)</code>.
17940 # 
17941 # Otherwise, returns a new array built by concatenating the +int+ copies of
17942 # +self+.
17943 # 
17944 #    [ 1, 2, 3 ] * 3    #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
17945 #    [ 1, 2, 3 ] * ","  #=> "1,2,3"
17946 def *; ''; end
17947 ##
17948 # Array Difference
17949 # 
17950 # Returns a new array that is a copy of the original array, removing any
17951 # items that also appear in +other_ary+. The order is preserved from the
17952 # original array.
17953 # 
17954 # It compares elements using their #hash and #eql? methods for efficiency.
17955 # 
17956 #    [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ]  #=>  [ 3, 3, 5 ]
17957 # 
17958 # If you need set-like behavior, see the library class Set.
17959 def -; []; end
17960 ##
17961 # Set Intersection --- Returns a new array containing elements common to the
17962 # two arrays, excluding any duplicates. The order is preserved from the
17963 # original array.
17964 # 
17965 # It compares elements using their #hash and #eql? methods for efficiency.
17966 # 
17967 #    [ 1, 1, 3, 5 ] & [ 1, 2, 3 ]                 #=> [ 1, 3 ]
17968 #    [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ]   #=> [ 'a', 'b' ]
17969 # 
17970 # See also Array#uniq.
17971 def &; []; end
17972 ##
17973 # Set Union --- Returns a new array by joining +ary+ with +other_ary+,
17974 # excluding any duplicates and preserving the order from the original array.
17975 # 
17976 # It compares elements using their #hash and #eql? methods for efficiency.
17977 # 
17978 #    [ "a", "b", "c" ] | [ "c", "d", "a" ]    #=> [ "a", "b", "c", "d" ]
17979 # 
17980 # See also Array#uniq.
17981 def |; []; end
17982 ##
17983 # Returns a new array by removing duplicate values in +self+.
17984 # 
17985 # If a block is given, it will use the return value of the block for comparison.
17986 # 
17987 # It compares values using their #hash and #eql? methods for efficiency.
17988 # 
17989 #    a = [ "a", "a", "b", "b", "c" ]
17990 #    a.uniq   # => ["a", "b", "c"]
17991 # 
17992 #    b = [["student","sam"], ["student","george"], ["teacher","matz"]]
17993 #    b.uniq { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
17994 def uniq; []; end
17995 ##
17996 # Removes duplicate elements from +self+.
17997 # 
17998 # If a block is given, it will use the return value of the block for
17999 # comparison.
18000 # 
18001 # It compares values using their #hash and #eql? methods for efficiency.
18002 # 
18003 # Returns +nil+ if no changes are made (that is, no duplicates are found).
18004 # 
18005 #    a = [ "a", "a", "b", "b", "c" ]
18006 #    a.uniq!   # => ["a", "b", "c"]
18007 # 
18008 #    b = [ "a", "b", "c" ]
18009 #    b.uniq!   # => nil
18010 # 
18011 #    c = [["student","sam"], ["student","george"], ["teacher","matz"]]
18012 #    c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
18013 def uniq!; [] || nil; end
18014 ##
18015 # Returns a copy of +self+ with all +nil+ elements removed.
18016 # 
18017 #    [ "a", nil, "b", nil, "c", nil ].compact
18018 #                      #=> [ "a", "b", "c" ]
18019 def compact; []; end
18020 ##
18021 # Removes +nil+ elements from the array.
18022 # 
18023 # Returns +nil+ if no changes were made, otherwise returns the array.
18024 # 
18025 #    [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
18026 #    [ "a", "b", "c" ].compact!           #=> nil
18027 def compact!; [] || nil; end
18028 ##
18029 # Returns a new array that is a one-dimensional flattening of +self+
18030 # (recursively).
18031 # 
18032 # That is, for every element that is an array, extract its elements into
18033 # the new array.
18034 # 
18035 # The optional +level+ argument determines the level of recursion to
18036 # flatten.
18037 # 
18038 #    s = [ 1, 2, 3 ]           #=> [1, 2, 3]
18039 #    t = [ 4, 5, 6, [7, 8] ]   #=> [4, 5, 6, [7, 8]]
18040 #    a = [ s, t, 9, 10 ]       #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
18041 #    a.flatten                 #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
18042 #    a = [ 1, 2, [3, [4, 5] ] ]
18043 #    a.flatten(1)              #=> [1, 2, 3, [4, 5]]
18044 def flatten; []; end
18045 ##
18046 # Flattens +self+ in place.
18047 # 
18048 # Returns +nil+ if no modifications were made (i.e., the array contains no
18049 # subarrays.)
18050 # 
18051 # The optional +level+ argument determines the level of recursion to flatten.
18052 # 
18053 #    a = [ 1, 2, [3, [4, 5] ] ]
18054 #    a.flatten!   #=> [1, 2, 3, 4, 5]
18055 #    a.flatten!   #=> nil
18056 #    a            #=> [1, 2, 3, 4, 5]
18057 #    a = [ 1, 2, [3, [4, 5] ] ]
18058 #    a.flatten!(1) #=> [1, 2, 3, [4, 5]]
18059 def flatten!; [] || nil; end
18060 ##
18061 # Returns the number of elements.
18062 # 
18063 # If an argument is given, counts the number of elements which equal +obj+
18064 # using <code>===</code>.
18065 # 
18066 # If a block is given, counts the number of elements for which the block
18067 # returns a true value.
18068 # 
18069 #    ary = [1, 2, 4, 2]
18070 #    ary.count                  #=> 4
18071 #    ary.count(2)               #=> 2
18072 #    ary.count { |x| x%2 == 0 } #=> 3
18073 def count; 0; end
18074 ##
18075 # Shuffles elements in +self+ in place.
18076 # 
18077 # The optional +rng+ argument will be used as the random number generator.
18078 def shuffle!; []; end
18079 ##
18080 # Returns a new array with elements of +self+ shuffled.
18081 # 
18082 #    a = [ 1, 2, 3 ]           #=> [1, 2, 3]
18083 #    a.shuffle                 #=> [2, 3, 1]
18084 # 
18085 # The optional +rng+ argument will be used as the random number generator.
18086 # 
18087 #    a.shuffle(random: Random.new(1))  #=> [1, 3, 2]
18088 def shuffle; []; end
18089 ##
18090 # Choose a random element or +n+ random elements from the array.
18091 # 
18092 # The elements are chosen by using random and unique indices into the array
18093 # in order to ensure that an element doesn't repeat itself unless the array
18094 # already contained duplicate elements.
18095 # 
18096 # If the array is empty the first form returns +nil+ and the second form
18097 # returns an empty array.
18098 # 
18099 # The optional +rng+ argument will be used as the random number generator.
18100 # 
18101 #    a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
18102 #    a.sample         #=> 7
18103 #    a.sample(4)      #=> [6, 4, 2, 5]
18104 def sample; []; end
18105 ##
18106 # Calls the given block for each element +n+ times or forever if +nil+ is
18107 # given.
18108 # 
18109 # Does nothing if a non-positive number is given or the array is empty.
18110 # 
18111 # Returns +nil+ if the loop has finished without getting interrupted.
18112 # 
18113 # If no block is given, an Enumerator is returned instead.
18114 # 
18115 #    a = ["a", "b", "c"]
18116 #    a.cycle { |x| puts x }     # print, a, b, c, a, b, c,.. forever.
18117 #    a.cycle(2) { |x| puts x }  # print, a, b, c, a, b, c.
18118 def cycle(n=null, &block); Enumerator.new; end
18119 ##
18120 # When invoked with a block, yield all permutations of length +n+ of the
18121 # elements of the array, then return the array itself.
18122 # 
18123 # If +n+ is not specified, yield all permutations of all elements.
18124 # 
18125 # The implementation makes no guarantees about the order in which the
18126 # permutations are yielded.
18127 # 
18128 # If no block is given, an Enumerator is returned instead.
18129 # 
18130 # Examples:
18131 # 
18132 #   a = [1, 2, 3]
18133 #   a.permutation.to_a    #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
18134 #   a.permutation(1).to_a #=> [[1],[2],[3]]
18135 #   a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
18136 #   a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
18137 #   a.permutation(0).to_a #=> [[]] # one permutation of length 0
18138 #   a.permutation(4).to_a #=> []   # no permutations of length 4
18139 def permutation(&block); Enumerator.new; end
18140 ##
18141 # When invoked with a block, yields all combinations of length +n+ of elements
18142 # from the array and then returns the array itself.
18143 # 
18144 # The implementation makes no guarantees about the order in which the
18145 # combinations are yielded.
18146 # 
18147 # If no block is given, an Enumerator is returned instead.
18148 # 
18149 # Examples:
18150 # 
18151 #     a = [1, 2, 3, 4]
18152 #     a.combination(1).to_a  #=> [[1],[2],[3],[4]]
18153 #     a.combination(2).to_a  #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
18154 #     a.combination(3).to_a  #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
18155 #     a.combination(4).to_a  #=> [[1,2,3,4]]
18156 #     a.combination(0).to_a  #=> [[]] # one combination of length 0
18157 #     a.combination(5).to_a  #=> []   # no combinations of length 5
18158 def combination(n, &block); Enumerator.new; end
18159 ##
18160 # When invoked with a block, yield all repeated permutations of length +n+ of
18161 # the elements of the array, then return the array itself.
18162 # 
18163 # The implementation makes no guarantees about the order in which the repeated
18164 # permutations are yielded.
18165 # 
18166 # If no block is given, an Enumerator is returned instead.
18167 # 
18168 # Examples:
18169 # 
18170 #     a = [1, 2]
18171 #     a.repeated_permutation(1).to_a  #=> [[1], [2]]
18172 #     a.repeated_permutation(2).to_a  #=> [[1,1],[1,2],[2,1],[2,2]]
18173 #     a.repeated_permutation(3).to_a  #=> [[1,1,1],[1,1,2],[1,2,1],[1,2,2],
18174 #                                     #    [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
18175 #     a.repeated_permutation(0).to_a  #=> [[]] # one permutation of length 0
18176 def repeated_permutation(n, &block); Enumerator.new; end
18177 ##
18178 # When invoked with a block, yields all repeated combinations of length +n+ of
18179 # elements from the array and then returns the array itself.
18180 # 
18181 # The implementation makes no guarantees about the order in which the repeated
18182 # combinations are yielded.
18183 # 
18184 # If no block is given, an Enumerator is returned instead.
18185 # 
18186 # Examples:
18187 # 
18188 #   a = [1, 2, 3]
18189 #   a.repeated_combination(1).to_a  #=> [[1], [2], [3]]
18190 #   a.repeated_combination(2).to_a  #=> [[1,1],[1,2],[1,3],[2,2],[2,3],[3,3]]
18191 #   a.repeated_combination(3).to_a  #=> [[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],
18192 #                                   #    [1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3]]
18193 #   a.repeated_combination(4).to_a  #=> [[1,1,1,1],[1,1,1,2],[1,1,1,3],[1,1,2,2],[1,1,2,3],
18194 #                                   #    [1,1,3,3],[1,2,2,2],[1,2,2,3],[1,2,3,3],[1,3,3,3],
18195 #                                   #    [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
18196 #   a.repeated_combination(0).to_a  #=> [[]] # one combination of length 0
18197 def repeated_combination(n, &block); Enumerator.new; end
18198 ##
18199 # Returns an array of all combinations of elements from all arrays.
18200 # 
18201 # The length of the returned array is the product of the length of +self+ and
18202 # the argument arrays.
18203 # 
18204 # If given a block, #product will yield all combinations and return +self+
18205 # instead.
18206 # 
18207 #    [1,2,3].product([4,5])     #=> [[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]]
18208 #    [1,2].product([1,2])       #=> [[1,1],[1,2],[2,1],[2,2]]
18209 #    [1,2].product([3,4],[5,6]) #=> [[1,3,5],[1,3,6],[1,4,5],[1,4,6],
18210 #                               #     [2,3,5],[2,3,6],[2,4,5],[2,4,6]]
18211 #    [1,2].product()            #=> [[1],[2]]
18212 #    [1,2].product([])          #=> []
18213 def product(); []; end
18214 ##
18215 # Returns first +n+ elements from the array.
18216 # 
18217 # If a negative number is given, raises an ArgumentError.
18218 # 
18219 # See also Array#drop
18220 # 
18221 #    a = [1, 2, 3, 4, 5, 0]
18222 #    a.take(3)             #=> [1, 2, 3]
18223 def take(n); []; end
18224 ##
18225 # Passes elements to the block until the block returns +nil+ or +false+, then
18226 # stops iterating and returns an array of all prior elements.
18227 # 
18228 # If no block is given, an Enumerator is returned instead.
18229 # 
18230 # See also Array#drop_while
18231 # 
18232 #    a = [1, 2, 3, 4, 5, 0]
18233 #    a.take_while { |i| i < 3 }  #=> [1, 2]
18234 def take_while(&block); Enumerator.new; end
18235 ##
18236 # Drops first +n+ elements from +ary+ and returns the rest of the elements in
18237 # an array.
18238 # 
18239 # If a negative number is given, raises an ArgumentError.
18240 # 
18241 # See also Array#take
18242 # 
18243 #    a = [1, 2, 3, 4, 5, 0]
18244 #    a.drop(3)             #=> [4, 5, 0]
18245 def drop(n); []; end
18246 ##
18247 # Drops elements up to, but not including, the first element for which the
18248 # block returns +nil+ or +false+ and returns an array containing the
18249 # remaining elements.
18250 # 
18251 # If no block is given, an Enumerator is returned instead.
18252 # 
18253 # See also Array#take_while
18254 # 
18255 #    a = [1, 2, 3, 4, 5, 0]
18256 #    a.drop_while {|i| i < 3 }   #=> [3, 4, 5, 0]
18257 def drop_while(&block); Enumerator.new; end
18258 ##
18259 # By using binary search, finds a value from this array which meets
18260 # the given condition in O(log n) where n is the size of the array.
18261 # 
18262 # You can use this method in two use cases: a find-minimum mode and
18263 # a find-any mode.  In either case, the elements of the array must be
18264 # monotone (or sorted) with respect to the block.
18265 # 
18266 # In find-minimum mode (this is a good choice for typical use case),
18267 # the block must return true or false, and there must be an index i
18268 # (0 <= i <= ary.size) so that:
18269 # 
18270 # - the block returns false for any element whose index is less than
18271 #   i, and
18272 # - the block returns true for any element whose index is greater
18273 #   than or equal to i.
18274 # 
18275 # This method returns the i-th element.  If i is equal to ary.size,
18276 # it returns nil.
18277 # 
18278 #    ary = [0, 4, 7, 10, 12]
18279 #    ary.bsearch {|x| x >=   4 } #=> 4
18280 #    ary.bsearch {|x| x >=   6 } #=> 7
18281 #    ary.bsearch {|x| x >=  -1 } #=> 0
18282 #    ary.bsearch {|x| x >= 100 } #=> nil
18283 # 
18284 # In find-any mode (this behaves like libc's bsearch(3)), the block
18285 # must return a number, and there must be two indices i and j
18286 # (0 <= i <= j <= ary.size) so that:
18287 # 
18288 # - the block returns a positive number for ary[k] if 0 <= k < i,
18289 # - the block returns zero for ary[k] if i <= k < j, and
18290 # - the block returns a negative number for ary[k] if
18291 #   j <= k < ary.size.
18292 # 
18293 # Under this condition, this method returns any element whose index
18294 # is within i...j.  If i is equal to j (i.e., there is no element
18295 # that satisfies the block), this method returns nil.
18296 # 
18297 #    ary = [0, 4, 7, 10, 12]
18298 #    # try to find v such that 4 <= v < 8
18299 #    ary.bsearch {|x| 1 - x / 4 } #=> 4 or 7
18300 #    # try to find v such that 8 <= v < 10
18301 #    ary.bsearch {|x| 4 - x / 2 } #=> nil
18302 # 
18303 # You must not mix the two modes at a time; the block must always
18304 # return either true/false, or always return a number.  It is
18305 # undefined which value is actually picked up at each iteration.
18306 def bsearch(&block); Object.new; end
18307 ##
18308 # Packs the contents of <i>arr</i> into a binary sequence according to
18309 # the directives in <i>aTemplateString</i> (see the table below)
18310 # Directives ``A,'' ``a,'' and ``Z'' may be followed by a count,
18311 # which gives the width of the resulting field. The remaining
18312 # directives also may take a count, indicating the number of array
18313 # elements to convert. If the count is an asterisk
18314 # (``<code>*</code>''), all remaining array elements will be
18315 # converted. Any of the directives ``<code>sSiIlL</code>'' may be
18316 # followed by an underscore (``<code>_</code>'') or
18317 # exclamation mark (``<code>!</code>'') to use the underlying
18318 # platform's native size for the specified type; otherwise, they use a
18319 # platform-independent size. Spaces are ignored in the template
18320 # string. See also <code>String#unpack</code>.
18321 # 
18322 #    a = [ "a", "b", "c" ]
18323 #    n = [ 65, 66, 67 ]
18324 #    a.pack("A3A3A3")   #=> "a  b  c  "
18325 #    a.pack("a3a3a3")   #=> "a\000\000b\000\000c\000\000"
18326 #    n.pack("ccc")      #=> "ABC"
18327 # 
18328 # Directives for +pack+.
18329 # 
18330 #  Integer      | Array   |
18331 #  Directive    | Element | Meaning
18332 #  ---------------------------------------------------------------------------
18333 #     C         | Integer | 8-bit unsigned (unsigned char)
18334 #     S         | Integer | 16-bit unsigned, native endian (uint16_t)
18335 #     L         | Integer | 32-bit unsigned, native endian (uint32_t)
18336 #     Q         | Integer | 64-bit unsigned, native endian (uint64_t)
18337 #               |         |
18338 #     c         | Integer | 8-bit signed (signed char)
18339 #     s         | Integer | 16-bit signed, native endian (int16_t)
18340 #     l         | Integer | 32-bit signed, native endian (int32_t)
18341 #     q         | Integer | 64-bit signed, native endian (int64_t)
18342 #               |         |
18343 #     S_, S!    | Integer | unsigned short, native endian
18344 #     I, I_, I! | Integer | unsigned int, native endian
18345 #     L_, L!    | Integer | unsigned long, native endian
18346 #               |         |
18347 #     s_, s!    | Integer | signed short, native endian
18348 #     i, i_, i! | Integer | signed int, native endian
18349 #     l_, l!    | Integer | signed long, native endian
18350 #               |         |
18351 #     S> L> Q>  | Integer | same as the directives without ">" except
18352 #     s> l> q>  |         | big endian
18353 #     S!> I!>   |         | (available since Ruby 1.9.3)
18354 #     L!>       |         | "S>" is same as "n"
18355 #     s!> i!>   |         | "L>" is same as "N"
18356 #     l!>       |         |
18357 #               |         |
18358 #     S< L< Q<  | Integer | same as the directives without "<" except
18359 #     s< l< q<  |         | little endian
18360 #     S!< I!<   |         | (available since Ruby 1.9.3)
18361 #     L!<       |         | "S<" is same as "v"
18362 #     s!< i!<   |         | "L<" is same as "V"
18363 #     l!<       |         |
18364 #               |         |
18365 #     n         | Integer | 16-bit unsigned, network (big-endian) byte order
18366 #     N         | Integer | 32-bit unsigned, network (big-endian) byte order
18367 #     v         | Integer | 16-bit unsigned, VAX (little-endian) byte order
18368 #     V         | Integer | 32-bit unsigned, VAX (little-endian) byte order
18369 #               |         |
18370 #     U         | Integer | UTF-8 character
18371 #     w         | Integer | BER-compressed integer
18372 # 
18373 #  Float        |         |
18374 #  Directive    |         | Meaning
18375 #  ---------------------------------------------------------------------------
18376 #     D, d      | Float   | double-precision, native format
18377 #     F, f      | Float   | single-precision, native format
18378 #     E         | Float   | double-precision, little-endian byte order
18379 #     e         | Float   | single-precision, little-endian byte order
18380 #     G         | Float   | double-precision, network (big-endian) byte order
18381 #     g         | Float   | single-precision, network (big-endian) byte order
18382 # 
18383 #  String       |         |
18384 #  Directive    |         | Meaning
18385 #  ---------------------------------------------------------------------------
18386 #     A         | String  | arbitrary binary string (space padded, count is width)
18387 #     a         | String  | arbitrary binary string (null padded, count is width)
18388 #     Z         | String  | same as ``a'', except that null is added with *
18389 #     B         | String  | bit string (MSB first)
18390 #     b         | String  | bit string (LSB first)
18391 #     H         | String  | hex string (high nibble first)
18392 #     h         | String  | hex string (low nibble first)
18393 #     u         | String  | UU-encoded string
18394 #     M         | String  | quoted printable, MIME encoding (see RFC2045)
18395 #     m         | String  | base64 encoded string (see RFC 2045, count is width)
18396 #               |         | (if count is 0, no line feed are added, see RFC 4648)
18397 #     P         | String  | pointer to a structure (fixed-length string)
18398 #     p         | String  | pointer to a null-terminated string
18399 # 
18400 #  Misc.        |         |
18401 #  Directive    |         | Meaning
18402 #  ---------------------------------------------------------------------------
18403 #     @         | ---     | moves to absolute position
18404 #     X         | ---     | back up a byte
18405 #     x         | ---     | null byte
18406 def pack ( aTemplateString ); ''; end
18407 end
18408 
18409 ##
18410 # A <code>Struct</code> is a convenient way to bundle a number of
18411 # attributes together, using accessor methods, without having to write
18412 # an explicit class.
18413 # 
18414 # The <code>Struct</code> class is a generator of specific classes,
18415 # each one of which is defined to hold a set of variables and their
18416 # accessors. In these examples, we'll call the generated class
18417 # ``<i>Customer</i>Class,'' and we'll show an example instance of that
18418 # class as ``<i>Customer</i>Inst.''
18419 # 
18420 # In the descriptions that follow, the parameter <i>symbol</i> refers
18421 # to a symbol, which is either a quoted string or a
18422 # <code>Symbol</code> (such as <code>:name</code>).
18423 class Struct < Object
18424 include Enumerable
18425 ##
18426 # Creates a new class, named by <i>aString</i>, containing accessor
18427 # methods for the given symbols. If the name <i>aString</i> is
18428 # omitted, an anonymous structure class will be created. Otherwise,
18429 # the name of this struct will appear as a constant in class
18430 # <code>Struct</code>, so it must be unique for all
18431 # <code>Struct</code>s in the system and should start with a capital
18432 # letter. Assigning a structure class to a constant effectively gives
18433 # the class the name of the constant.
18434 # 
18435 # If a block is given, it will be evaluated in the context of
18436 # <i>StructClass</i>, passing <i>StructClass</i> as a parameter.
18437 # 
18438 #    Customer = Struct.new(:name, :address) do
18439 #      def greeting
18440 #        "Hello #{name}!"
18441 #      end
18442 #    end
18443 #    Customer.new("Dave", "123 Main").greeting  # => "Hello Dave!"
18444 # 
18445 # <code>Struct::new</code> returns a new <code>Class</code> object,
18446 # which can then be used to create specific instances of the new
18447 # structure. The number of actual parameters must be
18448 # less than or equal to the number of attributes defined for this
18449 # class; unset parameters default to <code>nil</code>.  Passing too many
18450 # parameters will raise an <code>ArgumentError</code>.
18451 # 
18452 # The remaining methods listed in this section (class and instance)
18453 # are defined for this generated class.
18454 # 
18455 #    # Create a structure with a name in Struct
18456 #    Struct.new("Customer", :name, :address)    #=> Struct::Customer
18457 #    Struct::Customer.new("Dave", "123 Main")   #=> #<struct Struct::Customer name="Dave", address="123 Main">
18458 # 
18459 #    # Create a structure named by its constant
18460 #    Customer = Struct.new(:name, :address)     #=> Customer
18461 #    Customer.new("Dave", "123 Main")           #=> #<struct Customer name="Dave", address="123 Main">
18462 def self.new(); end
18463 ##
18464 # Creates a new class, named by <i>aString</i>, containing accessor
18465 # methods for the given symbols. If the name <i>aString</i> is
18466 # omitted, an anonymous structure class will be created. Otherwise,
18467 # the name of this struct will appear as a constant in class
18468 # <code>Struct</code>, so it must be unique for all
18469 # <code>Struct</code>s in the system and should start with a capital
18470 # letter. Assigning a structure class to a constant effectively gives
18471 # the class the name of the constant.
18472 # 
18473 # If a block is given, it will be evaluated in the context of
18474 # <i>StructClass</i>, passing <i>StructClass</i> as a parameter.
18475 # 
18476 #    Customer = Struct.new(:name, :address) do
18477 #      def greeting
18478 #        "Hello #{name}!"
18479 #      end
18480 #    end
18481 #    Customer.new("Dave", "123 Main").greeting  # => "Hello Dave!"
18482 # 
18483 # <code>Struct::new</code> returns a new <code>Class</code> object,
18484 # which can then be used to create specific instances of the new
18485 # structure. The number of actual parameters must be
18486 # less than or equal to the number of attributes defined for this
18487 # class; unset parameters default to <code>nil</code>.  Passing too many
18488 # parameters will raise an <code>ArgumentError</code>.
18489 # 
18490 # The remaining methods listed in this section (class and instance)
18491 # are defined for this generated class.
18492 # 
18493 #    # Create a structure with a name in Struct
18494 #    Struct.new("Customer", :name, :address)    #=> Struct::Customer
18495 #    Struct::Customer.new("Dave", "123 Main")   #=> #<struct Struct::Customer name="Dave", address="123 Main">
18496 # 
18497 #    # Create a structure named by its constant
18498 #    Customer = Struct.new(:name, :address)     #=> Customer
18499 #    Customer.new("Dave", "123 Main")           #=> #<struct Customer name="Dave", address="123 Main">
18500 def self.[]; Object.new; end
18501 ##
18502 # Equality---Returns <code>true</code> if <i>other_struct</i> is
18503 # equal to this one: they must be of the same class as generated by
18504 # <code>Struct::new</code>, and the values of all instance variables
18505 # must be equal (according to <code>Object#==</code>).
18506 # 
18507 #    Customer = Struct.new(:name, :address, :zip)
18508 #    joe   = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18509 #    joejr = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18510 #    jane  = Customer.new("Jane Doe", "456 Elm, Anytown NC", 12345)
18511 #    joe == joejr   #=> true
18512 #    joe == jane    #=> false
18513 def ==; true || false; end
18514 ##
18515 # Two structures are equal if they are the same object, or if all their
18516 # fields are equal (using <code>eql?</code>).
18517 def eql?(other); true || false; end
18518 ##
18519 # Return a hash value based on this struct's contents.
18520 def hash; 0; end
18521 ##
18522 # Describe the contents of this struct in a string.
18523 def to_s; ''; end
18524 ##
18525 # Describe the contents of this struct in a string.
18526 def inspect; ''; end
18527 ##
18528 # Returns the values for this instance as an array.
18529 # 
18530 #    Customer = Struct.new(:name, :address, :zip)
18531 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18532 #    joe.to_a[1]   #=> "123 Maple, Anytown NC"
18533 def to_a; []; end
18534 ##
18535 # Returns the values for this instance as an array.
18536 # 
18537 #    Customer = Struct.new(:name, :address, :zip)
18538 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18539 #    joe.to_a[1]   #=> "123 Maple, Anytown NC"
18540 def values; []; end
18541 ##
18542 # Returns the values for this instance as a hash with keys
18543 # corresponding to the instance variable name.
18544 # 
18545 #    Customer = Struct.new(:name, :address, :zip)
18546 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18547 #    joe.to_h[:address]   #=> "123 Maple, Anytown NC"
18548 def to_h; {}; end
18549 ##
18550 # Returns the number of instance variables.
18551 # 
18552 #    Customer = Struct.new(:name, :address, :zip)
18553 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18554 #    joe.length   #=> 3
18555 def length; 0; end
18556 ##
18557 # Returns the number of instance variables.
18558 # 
18559 #    Customer = Struct.new(:name, :address, :zip)
18560 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18561 #    joe.length   #=> 3
18562 def size; 0; end
18563 ##
18564 # Calls <i>block</i> once for each instance variable, passing the
18565 # value as a parameter.
18566 # 
18567 # If no block is given, an enumerator is returned instead.
18568 # 
18569 #    Customer = Struct.new(:name, :address, :zip)
18570 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18571 #    joe.each {|x| puts(x) }
18572 # 
18573 # <em>produces:</em>
18574 # 
18575 #    Joe Smith
18576 #    123 Maple, Anytown NC
18577 #    12345
18578 def each(&block); Enumerator.new; end
18579 ##
18580 # Calls <i>block</i> once for each instance variable, passing the name
18581 # (as a symbol) and the value as parameters.
18582 # 
18583 # If no block is given, an enumerator is returned instead.
18584 # 
18585 #    Customer = Struct.new(:name, :address, :zip)
18586 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18587 #    joe.each_pair {|name, value| puts("#{name} => #{value}") }
18588 # 
18589 # <em>produces:</em>
18590 # 
18591 #    name => Joe Smith
18592 #    address => 123 Maple, Anytown NC
18593 #    zip => 12345
18594 def each_pair(&block); Enumerator.new; end
18595 ##
18596 # Attribute Assignment---Assigns to the instance variable named by
18597 # <i>symbol</i> or <i>fixnum</i> the value <i>obj</i> and
18598 # returns it. Will raise a <code>NameError</code> if the named
18599 # variable does not exist, or an <code>IndexError</code> if the index
18600 # is out of range.
18601 # 
18602 #    Customer = Struct.new(:name, :address, :zip)
18603 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18604 # 
18605 #    joe["name"] = "Luke"
18606 #    joe[:zip]   = "90210"
18607 # 
18608 #    joe.name   #=> "Luke"
18609 #    joe.zip    #=> "90210"
18610 def []=; Object.new; end
18611 ##
18612 # Invokes the block passing in successive elements from
18613 # <i>struct</i>, returning an array containing those elements
18614 # for which the block returns a true value (equivalent to
18615 # <code>Enumerable#select</code>).
18616 # 
18617 #    Lots = Struct.new(:a, :b, :c, :d, :e, :f)
18618 #    l = Lots.new(11, 22, 33, 44, 55, 66)
18619 #    l.select {|v| (v % 2).zero? }   #=> [22, 44, 66]
18620 def select(&block); Enumerator.new; end
18621 ##
18622 # Returns an array containing the elements in
18623 # +self+ corresponding to the given selector(s). The selectors
18624 # may be either integer indices or ranges.
18625 # See also </code>.select<code>.
18626 # 
18627 #    a = %w{ a b c d e f }
18628 #    a.values_at(1, 3, 5)
18629 #    a.values_at(1, 3, 5, 7)
18630 #    a.values_at(-1, -3, -5, -7)
18631 #    a.values_at(1..3, 2...5)
18632 def values_at(); []; end
18633 ##
18634 # Returns an array of symbols representing the names of the instance
18635 # variables.
18636 # 
18637 #    Customer = Struct.new(:name, :address, :zip)
18638 #    joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
18639 #    joe.members   #=> [:name, :address, :zip]
18640 def members; []; end
18641 end
18642 
18643 ##
18644 # Raised when given an invalid regexp expression.
18645 # 
18646 #    Regexp.new("?")
18647 # 
18648 # <em>raises the exception:</em>
18649 # 
18650 #    RegexpError: target of repeat operator is not specified: /?/
18651 class RegexpError < StandardError
18652 end
18653 
18654 ##
18655 # A <code>Regexp</code> holds a regular expression, used to match a pattern
18656 # against strings. Regexps are created using the <code>/.../</code> and
18657 # <code>%r{...}</code> literals, and by the <code>Regexp::new</code>
18658 # constructor.
18659 # 
18660 # Regular expressions (<i>regexp</i>s) are patterns which describe the
18661 # contents of a string. They're used for testing whether a string contains a
18662 # given pattern, or extracting the portions that match. They are created
18663 # with the <tt>/</tt><i>pat</i><tt>/</tt> and
18664 # <tt>%r{</tt><i>pat</i><tt>}</tt> literals or the <tt>Regexp.new</tt>
18665 # constructor.
18666 # 
18667 # A regexp is usually delimited with forward slashes (<tt>/</tt>). For
18668 # example:
18669 # 
18670 #     /hay/ =~ 'haystack'   #=> 0
18671 #     /y/.match('haystack') #=> #<MatchData "y">
18672 # 
18673 # If a string contains the pattern it is said to <i>match</i>. A literal
18674 # string matches itself.
18675 # 
18676 #     # 'haystack' does not contain the pattern 'needle', so doesn't match.
18677 #     /needle/.match('haystack') #=> nil
18678 #     # 'haystack' does contain the pattern 'hay', so it matches
18679 #     /hay/.match('haystack')    #=> #<MatchData "hay">
18680 # 
18681 # Specifically, <tt>/st/</tt> requires that the string contains the letter
18682 # _s_ followed by the letter _t_, so it matches _haystack_, also.
18683 # 
18684 # == <tt>=~</tt> and Regexp#match
18685 # 
18686 # Pattern matching may be achieved by using <tt>=~</tt> operator or Regexp#match
18687 # method.
18688 # 
18689 # === <tt>=~</tt> operator
18690 # 
18691 # <tt>=~</tt> is Ruby's basic pattern-matching operator.  When one operand is a
18692 # regular expression and the other is a string then the regular expression is
18693 # used as a pattern to match against the string.  (This operator is equivalently
18694 # defined by Regexp and String so the order of String and Regexp do not matter.
18695 # Other classes may have different implementations of <tt>=~</tt>.)  If a match
18696 # is found, the operator returns index of first match in string, otherwise it
18697 # returns +nil+.
18698 # 
18699 #     /hay/ =~ 'haystack'   #=> 0
18700 #     'haystack' =~ /hay/   #=> 0
18701 #     /a/   =~ 'haystack'   #=> 1
18702 #     /u/   =~ 'haystack'   #=> nil
18703 # 
18704 # Using <tt>=~</tt> operator with a String and Regexp the <tt>$~</tt> global
18705 # variable is set after a successful match.  <tt>$~</tt> holds a MatchData
18706 # object. Regexp.last_match is equivalent to <tt>$~</tt>.
18707 # 
18708 # === Regexp#match method
18709 # 
18710 # #match method return a MatchData object :
18711 # 
18712 #     /st/.match('haystack')   #=> #<MatchData "st">
18713 # 
18714 # == Metacharacters and Escapes
18715 # 
18716 # The following are <i>metacharacters</i> <tt>(</tt>, <tt>)</tt>,
18717 # <tt>[</tt>, <tt>]</tt>, <tt>{</tt>, <tt>}</tt>, <tt>.</tt>, <tt>?</tt>,
18718 # <tt>+</tt>, <tt>*</tt>. They have a specific meaning when appearing in a
18719 # pattern. To match them literally they must be backslash-escaped. To match
18720 # a backslash literally backslash-escape that: <tt>\\\\\\</tt>.
18721 # 
18722 #     /1 \+ 2 = 3\?/.match('Does 1 + 2 = 3?') #=> #<MatchData "1 + 2 = 3?">
18723 # 
18724 # Patterns behave like double-quoted strings so can contain the same
18725 # backslash escapes.
18726 # 
18727 #     /\s\u{6771 4eac 90fd}/.match("Go to 東京都")
18728 #         #=> #<MatchData " 東京都">
18729 # 
18730 # Arbitrary Ruby expressions can be embedded into patterns with the
18731 # <tt>#{...}</tt> construct.
18732 # 
18733 #     place = "東京都"
18734 #     /#{place}/.match("Go to 東京都")
18735 #         #=> #<MatchData "東京都">
18736 # 
18737 # == Character Classes
18738 # 
18739 # A <i>character class</i> is delimited with square brackets (<tt>[</tt>,
18740 # <tt>]</tt>) and lists characters that may appear at that point in the
18741 # match. <tt>/[ab]/</tt> means _a_ or _b_, as opposed to <tt>/ab/</tt> which
18742 # means _a_ followed by _b_.
18743 # 
18744 #     /W[aeiou]rd/.match("Word") #=> #<MatchData "Word">
18745 # 
18746 # Within a character class the hyphen (<tt>-</tt>) is a metacharacter
18747 # denoting an inclusive range of characters. <tt>[abcd]</tt> is equivalent
18748 # to <tt>[a-d]</tt>. A range can be followed by another range, so
18749 # <tt>[abcdwxyz]</tt> is equivalent to <tt>[a-dw-z]</tt>. The order in which
18750 # ranges or individual characters appear inside a character class is
18751 # irrelevant.
18752 # 
18753 #     /[0-9a-f]/.match('9f') #=> #<MatchData "9">
18754 #     /[9f]/.match('9f')     #=> #<MatchData "9">
18755 # 
18756 # If the first character of a character class is a caret (<tt>^</tt>) the
18757 # class is inverted: it matches any character _except_ those named.
18758 # 
18759 #     /[^a-eg-z]/.match('f') #=> #<MatchData "f">
18760 # 
18761 # A character class may contain another character class. By itself this
18762 # isn't useful because <tt>[a-z[0-9]]</tt> describes the same set as
18763 # <tt>[a-z0-9]</tt>. However, character classes also support the <tt>&&</tt>
18764 # operator which performs set intersection on its arguments. The two can be
18765 # combined as follows:
18766 # 
18767 #     /[a-w&&[^c-g]z]/ # ([a-w] AND ([^c-g] OR z))
18768 #     # This is equivalent to:
18769 #     /[abh-w]/
18770 # 
18771 # The following metacharacters also behave like character classes:
18772 # 
18773 # * <tt>/./</tt> - Any character except a newline.
18774 # * <tt>/./m</tt> - Any character (the +m+ modifier enables multiline mode)
18775 # * <tt>/\w/</tt> - A word character (<tt>[a-zA-Z0-9_]</tt>)
18776 # * <tt>/\W/</tt> - A non-word character (<tt>[^a-zA-Z0-9_]</tt>)
18777 # * <tt>/\d/</tt> - A digit character (<tt>[0-9]</tt>)
18778 # * <tt>/\D/</tt> - A non-digit character (<tt>[^0-9]</tt>)
18779 # * <tt>/\h/</tt> - A hexdigit character (<tt>[0-9a-fA-F]</tt>)
18780 # * <tt>/\H/</tt> - A non-hexdigit character (<tt>[^0-9a-fA-F]</tt>)
18781 # * <tt>/\s/</tt> - A whitespace character: <tt>/[ \t\r\n\f]/</tt>
18782 # * <tt>/\S/</tt> - A non-whitespace character: <tt>/[^ \t\r\n\f]/</tt>
18783 # 
18784 # POSIX <i>bracket expressions</i> are also similar to character classes.
18785 # They provide a portable alternative to the above, with the added benefit
18786 # that they encompass non-ASCII characters. For instance, <tt>/\d/</tt>
18787 # matches only the ASCII decimal digits (0-9); whereas <tt>/[[:digit:]]/</tt>
18788 # matches any character in the Unicode _Nd_ category.
18789 # 
18790 # * <tt>/[[:alnum:]]/</tt> - Alphabetic and numeric character
18791 # * <tt>/[[:alpha:]]/</tt> - Alphabetic character
18792 # * <tt>/[[:blank:]]/</tt> - Space or tab
18793 # * <tt>/[[:cntrl:]]/</tt> - Control character
18794 # * <tt>/[[:digit:]]/</tt> - Digit
18795 # * <tt>/[[:graph:]]/</tt> - Non-blank character (excludes spaces, control
18796 #   characters, and similar)
18797 # * <tt>/[[:lower:]]/</tt> - Lowercase alphabetical character
18798 # * <tt>/[[:print:]]/</tt> - Like [:graph:], but includes the space character
18799 # * <tt>/[[:punct:]]/</tt> - Punctuation character
18800 # * <tt>/[[:space:]]/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
18801 #   carriage return, etc.)
18802 # * <tt>/[[:upper:]]/</tt> - Uppercase alphabetical
18803 # * <tt>/[[:xdigit:]]/</tt> - Digit allowed in a hexadecimal number (i.e.,
18804 #   0-9a-fA-F)
18805 # 
18806 # Ruby also supports the following non-POSIX character classes:
18807 # 
18808 # * <tt>/[[:word:]]/</tt> - A character in one of the following Unicode
18809 #   general categories _Letter_, _Mark_, _Number_,
18810 #   <i>Connector_Punctuation</i>
18811 # * <tt>/[[:ascii:]]/</tt> - A character in the ASCII character set
18812 # 
18813 #     # U+06F2 is "EXTENDED ARABIC-INDIC DIGIT TWO"
18814 #     /[[:digit:]]/.match("\u06F2")    #=> #<MatchData "\u{06F2}">
18815 #     /[[:upper:]][[:lower:]]/.match("Hello") #=> #<MatchData "He">
18816 #     /[[:xdigit:]][[:xdigit:]]/.match("A6")  #=> #<MatchData "A6">
18817 # 
18818 # == Repetition
18819 # 
18820 # The constructs described so far match a single character. They can be
18821 # followed by a repetition metacharacter to specify how many times they need
18822 # to occur. Such metacharacters are called <i>quantifiers</i>.
18823 # 
18824 # * <tt>*</tt> - Zero or more times
18825 # * <tt>+</tt> - One or more times
18826 # * <tt>?</tt> - Zero or one times (optional)
18827 # * <tt>{</tt><i>n</i><tt>}</tt> - Exactly <i>n</i> times
18828 # * <tt>{</tt><i>n</i><tt>,}</tt> - <i>n</i> or more times
18829 # * <tt>{,</tt><i>m</i><tt>}</tt> - <i>m</i> or less times
18830 # * <tt>{</tt><i>n</i><tt>,</tt><i>m</i><tt>}</tt> - At least <i>n</i> and
18831 #   at most <i>m</i> times
18832 # 
18833 #     # At least one uppercase character ('H'), at least one lowercase
18834 #     # character ('e'), two 'l' characters, then one 'o'
18835 #     "Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/) #=> #<MatchData "Hello">
18836 # 
18837 # Repetition is <i>greedy</i> by default: as many occurrences as possible
18838 # are matched while still allowing the overall match to succeed. By
18839 # contrast, <i>lazy</i> matching makes the minimal amount of matches
18840 # necessary for overall success. A greedy metacharacter can be made lazy by
18841 # following it with <tt>?</tt>.
18842 # 
18843 #     # Both patterns below match the string. The first uses a greedy
18844 #     # quantifier so '.+' matches '<a><b>'; the second uses a lazy
18845 #     # quantifier so '.+?' matches '<a>'.
18846 #     /<.+>/.match("<a><b>")  #=> #<MatchData "<a><b>">
18847 #     /<.+?>/.match("<a><b>") #=> #<MatchData "<a>">
18848 # 
18849 # A quantifier followed by <tt>+</tt> matches <i>possessively</i>: once it
18850 # has matched it does not backtrack. They behave like greedy quantifiers,
18851 # but having matched they refuse to "give up" their match even if this
18852 # jeopardises the overall match.
18853 # 
18854 # == Capturing
18855 # 
18856 # Parentheses can be used for <i>capturing</i>. The text enclosed by the
18857 # <i>n</i><sup>th</sup> group of parentheses can be subsequently referred to
18858 # with <i>n</i>. Within a pattern use the <i>backreference</i>
18859 # <tt>\n</tt>; outside of the pattern use
18860 # <tt>MatchData[</tt><i>n</i><tt>]</tt>.
18861 # 
18862 #     # 'at' is captured by the first group of parentheses, then referred to
18863 #     # later with \1
18864 #     /[csh](..) [csh]\1 in/.match("The cat sat in the hat")
18865 #         #=> #<MatchData "cat sat in" 1:"at">
18866 #     # Regexp#match returns a MatchData object which makes the captured
18867 #     # text available with its #[] method.
18868 #     /[csh](..) [csh]\1 in/.match("The cat sat in the hat")[1] #=> 'at'
18869 # 
18870 # Capture groups can be referred to by name when defined with the
18871 # <tt>(?<</tt><i>name</i><tt>>)</tt> or <tt>(?'</tt><i>name</i><tt>')</tt>
18872 # constructs.
18873 # 
18874 #     /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")
18875 #         => #<MatchData "$3.67" dollars:"3" cents:"67">
18876 #     /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")[:dollars] #=> "3"
18877 # 
18878 # Named groups can be backreferenced with <tt>\k<</tt><i>name</i><tt>></tt>,
18879 # where _name_ is the group name.
18880 # 
18881 #     /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
18882 #         #=> #<MatchData "ototo" vowel:"o">
18883 # 
18884 # *Note*: A regexp can't use named backreferences and numbered
18885 # backreferences simultaneously.
18886 # 
18887 # When named capture groups are used with a literal regexp on the left-hand
18888 # side of an expression and the <tt>=~</tt> operator, the captured text is
18889 # also assigned to local variables with corresponding names.
18890 # 
18891 #     /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ "$3.67" #=> 0
18892 #     dollars #=> "3"
18893 # 
18894 # == Grouping
18895 # 
18896 # Parentheses also <i>group</i> the terms they enclose, allowing them to be
18897 # quantified as one <i>atomic</i> whole.
18898 # 
18899 #     # The pattern below matches a vowel followed by 2 word characters:
18900 #     # 'aen'
18901 #     /[aeiou]\w{2}/.match("Caenorhabditis elegans") #=> #<MatchData "aen">
18902 #     # Whereas the following pattern matches a vowel followed by a word
18903 #     # character, twice, i.e. <tt>[aeiou]\w[aeiou]\w</tt>: 'enor'.
18904 #     /([aeiou]\w){2}/.match("Caenorhabditis elegans")
18905 #         #=> #<MatchData "enor" 1:"or">
18906 # 
18907 # The <tt>(?:</tt>...<tt>)</tt> construct provides grouping without
18908 # capturing. That is, it combines the terms it contains into an atomic whole
18909 # without creating a backreference. This benefits performance at the slight
18910 # expense of readability.
18911 # 
18912 #     # The group of parentheses captures 'n' and the second 'ti'. The
18913 #     # second group is referred to later with the backreference \2
18914 #     /I(n)ves(ti)ga\2ons/.match("Investigations")
18915 #         #=> #<MatchData "Investigations" 1:"n" 2:"ti">
18916 #     # The first group of parentheses is now made non-capturing with '?:',
18917 #     # so it still matches 'n', but doesn't create the backreference. Thus,
18918 #     # the backreference \1 now refers to 'ti'.
18919 #     /I(?:n)ves(ti)ga\1ons/.match("Investigations")
18920 #         #=> #<MatchData "Investigations" 1:"ti">
18921 # 
18922 # === Atomic Grouping
18923 # 
18924 # Grouping can be made <i>atomic</i> with
18925 # <tt>(?></tt><i>pat</i><tt>)</tt>. This causes the subexpression <i>pat</i>
18926 # to be matched independently of the rest of the expression such that what
18927 # it matches becomes fixed for the remainder of the match, unless the entire
18928 # subexpression must be abandoned and subsequently revisited. In this
18929 # way <i>pat</i> is treated as a non-divisible whole. Atomic grouping is
18930 # typically used to optimise patterns so as to prevent the regular
18931 # expression engine from backtracking needlessly.
18932 # 
18933 #     # The <tt>"</tt> in the pattern below matches the first character of
18934 #     # the string, then <tt>.*</tt> matches <i>Quote"</i>. This causes the
18935 #     # overall match to fail, so the text matched by <tt>.*</tt> is
18936 #     # backtracked by one position, which leaves the final character of the
18937 #     # string available to match <tt>"</tt>
18938 #           /".*"/.match('"Quote"')     #=> #<MatchData "\"Quote\"">
18939 #     # If <tt>.*</tt> is grouped atomically, it refuses to backtrack
18940 #     # <i>Quote"</i>, even though this means that the overall match fails
18941 #     /"(?>.*)"/.match('"Quote"') #=> nil
18942 # 
18943 # == Subexpression Calls
18944 # 
18945 # The <tt>\g<</tt><i>name</i><tt>></tt> syntax matches the previous
18946 # subexpression named _name_, which can be a group name or number, again.
18947 # This differs from backreferences in that it re-executes the group rather
18948 # than simply trying to re-match the same text.
18949 # 
18950 #     # Matches a <i>(</i> character and assigns it to the <tt>paren</tt>
18951 #     # group, tries to call that the <tt>paren</tt> sub-expression again
18952 #     # but fails, then matches a literal <i>)</i>.
18953 #     /\A(?<paren>\(\g<paren>*\))*\z/ =~ '()'
18954 # 
18955 # 
18956 #     /\A(?<paren>\(\g<paren>*\))*\z/ =~ '(())' #=> 0
18957 #     # ^1
18958 #     #      ^2
18959 #     #           ^3
18960 #     #                 ^4
18961 #     #      ^5
18962 #     #           ^6
18963 #     #                      ^7
18964 #     #                       ^8
18965 #     #                       ^9
18966 #     #                           ^10
18967 # 
18968 # 1.  Matches at the beginning of the string, i.e. before the first
18969 #     character.
18970 # 2.  Enters a named capture group called <tt>paren</tt>
18971 # 3.  Matches a literal <i>(</i>, the first character in the string
18972 # 4.  Calls the <tt>paren</tt> group again, i.e. recurses back to the
18973 #     second step
18974 # 5.  Re-enters the <tt>paren</tt> group
18975 # 6.  Matches a literal <i>(</i>, the second character in the
18976 #     string
18977 # 7.  Try to call <tt>paren</tt> a third time, but fail because
18978 #     doing so would prevent an overall successful match
18979 # 8.  Match a literal <i>)</i>, the third character in the string.
18980 #     Marks the end of the second recursive call
18981 # 9.  Match a literal <i>)</i>, the fourth character in the string
18982 # 10. Match the end of the string
18983 # 
18984 # == Alternation
18985 # 
18986 # The vertical bar metacharacter (<tt>|</tt>) combines two expressions into
18987 # a single one that matches either of the expressions. Each expression is an
18988 # <i>alternative</i>.
18989 # 
18990 #     /\w(and|or)\w/.match("Feliformia") #=> #<MatchData "form" 1:"or">
18991 #     /\w(and|or)\w/.match("furandi")    #=> #<MatchData "randi" 1:"and">
18992 #     /\w(and|or)\w/.match("dissemblance") #=> nil
18993 # 
18994 # == Character Properties
18995 # 
18996 # The <tt>\p{}</tt> construct matches characters with the named property,
18997 # much like POSIX bracket classes.
18998 # 
18999 # * <tt>/\p{Alnum}/</tt> - Alphabetic and numeric character
19000 # * <tt>/\p{Alpha}/</tt> - Alphabetic character
19001 # * <tt>/\p{Blank}/</tt> - Space or tab
19002 # * <tt>/\p{Cntrl}/</tt> - Control character
19003 # * <tt>/\p{Digit}/</tt> - Digit
19004 # * <tt>/\p{Graph}/</tt> - Non-blank character (excludes spaces, control
19005 #   characters, and similar)
19006 # * <tt>/\p{Lower}/</tt> - Lowercase alphabetical character
19007 # * <tt>/\p{Print}/</tt> - Like <tt>\p{Graph}</tt>, but includes the space character
19008 # * <tt>/\p{Punct}/</tt> - Punctuation character
19009 # * <tt>/\p{Space}/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
19010 #   carriage return, etc.)
19011 # * <tt>/\p{Upper}/</tt> - Uppercase alphabetical
19012 # * <tt>/\p{XDigit}/</tt> - Digit allowed in a hexadecimal number (i.e., 0-9a-fA-F)
19013 # * <tt>/\p{Word}/</tt> - A member of one of the following Unicode general
19014 #   category <i>Letter</i>, <i>Mark</i>, <i>Number</i>,
19015 #   <i>Connector\_Punctuation</i>
19016 # * <tt>/\p{ASCII}/</tt> - A character in the ASCII character set
19017 # * <tt>/\p{Any}/</tt> - Any Unicode character (including unassigned
19018 #   characters)
19019 # * <tt>/\p{Assigned}/</tt> - An assigned character
19020 # 
19021 # A Unicode character's <i>General Category</i> value can also be matched
19022 # with <tt>\p{</tt><i>Ab</i><tt>}</tt> where <i>Ab</i> is the category's
19023 # abbreviation as described below:
19024 # 
19025 # * <tt>/\p{L}/</tt> - 'Letter'
19026 # * <tt>/\p{Ll}/</tt> - 'Letter: Lowercase'
19027 # * <tt>/\p{Lm}/</tt> - 'Letter: Mark'
19028 # * <tt>/\p{Lo}/</tt> - 'Letter: Other'
19029 # * <tt>/\p{Lt}/</tt> - 'Letter: Titlecase'
19030 # * <tt>/\p{Lu}/</tt> - 'Letter: Uppercase
19031 # * <tt>/\p{Lo}/</tt> - 'Letter: Other'
19032 # * <tt>/\p{M}/</tt> - 'Mark'
19033 # * <tt>/\p{Mn}/</tt> - 'Mark: Nonspacing'
19034 # * <tt>/\p{Mc}/</tt> - 'Mark: Spacing Combining'
19035 # * <tt>/\p{Me}/</tt> - 'Mark: Enclosing'
19036 # * <tt>/\p{N}/</tt> - 'Number'
19037 # * <tt>/\p{Nd}/</tt> - 'Number: Decimal Digit'
19038 # * <tt>/\p{Nl}/</tt> - 'Number: Letter'
19039 # * <tt>/\p{No}/</tt> - 'Number: Other'
19040 # * <tt>/\p{P}/</tt> - 'Punctuation'
19041 # * <tt>/\p{Pc}/</tt> - 'Punctuation: Connector'
19042 # * <tt>/\p{Pd}/</tt> - 'Punctuation: Dash'
19043 # * <tt>/\p{Ps}/</tt> - 'Punctuation: Open'
19044 # * <tt>/\p{Pe}/</tt> - 'Punctuation: Close'
19045 # * <tt>/\p{Pi}/</tt> - 'Punctuation: Initial Quote'
19046 # * <tt>/\p{Pf}/</tt> - 'Punctuation: Final Quote'
19047 # * <tt>/\p{Po}/</tt> - 'Punctuation: Other'
19048 # * <tt>/\p{S}/</tt> - 'Symbol'
19049 # * <tt>/\p{Sm}/</tt> - 'Symbol: Math'
19050 # * <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
19051 # * <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
19052 # * <tt>/\p{Sk}/</tt> - 'Symbol: Modifier'
19053 # * <tt>/\p{So}/</tt> - 'Symbol: Other'
19054 # * <tt>/\p{Z}/</tt> - 'Separator'
19055 # * <tt>/\p{Zs}/</tt> - 'Separator: Space'
19056 # * <tt>/\p{Zl}/</tt> - 'Separator: Line'
19057 # * <tt>/\p{Zp}/</tt> - 'Separator: Paragraph'
19058 # * <tt>/\p{C}/</tt> - 'Other'
19059 # * <tt>/\p{Cc}/</tt> - 'Other: Control'
19060 # * <tt>/\p{Cf}/</tt> - 'Other: Format'
19061 # * <tt>/\p{Cn}/</tt> - 'Other: Not Assigned'
19062 # * <tt>/\p{Co}/</tt> - 'Other: Private Use'
19063 # * <tt>/\p{Cs}/</tt> - 'Other: Surrogate'
19064 # 
19065 # Lastly, <tt>\p{}</tt> matches a character's Unicode <i>script</i>. The
19066 # following scripts are supported: <i>Arabic</i>, <i>Armenian</i>,
19067 # <i>Balinese</i>, <i>Bengali</i>, <i>Bopomofo</i>, <i>Braille</i>,
19068 # <i>Buginese</i>, <i>Buhid</i>, <i>Canadian_Aboriginal</i>, <i>Carian</i>,
19069 # <i>Cham</i>, <i>Cherokee</i>, <i>Common</i>, <i>Coptic</i>,
19070 # <i>Cuneiform</i>, <i>Cypriot</i>, <i>Cyrillic</i>, <i>Deseret</i>,
19071 # <i>Devanagari</i>, <i>Ethiopic</i>, <i>Georgian</i>, <i>Glagolitic</i>,
19072 # <i>Gothic</i>, <i>Greek</i>, <i>Gujarati</i>, <i>Gurmukhi</i>, <i>Han</i>,
19073 # <i>Hangul</i>, <i>Hanunoo</i>, <i>Hebrew</i>, <i>Hiragana</i>,
19074 # <i>Inherited</i>, <i>Kannada</i>, <i>Katakana</i>, <i>Kayah_Li</i>,
19075 # <i>Kharoshthi</i>, <i>Khmer</i>, <i>Lao</i>, <i>Latin</i>, <i>Lepcha</i>,
19076 # <i>Limbu</i>, <i>Linear_B</i>, <i>Lycian</i>, <i>Lydian</i>,
19077 # <i>Malayalam</i>, <i>Mongolian</i>, <i>Myanmar</i>, <i>New_Tai_Lue</i>,
19078 # <i>Nko</i>, <i>Ogham</i>, <i>Ol_Chiki</i>, <i>Old_Italic</i>,
19079 # <i>Old_Persian</i>, <i>Oriya</i>, <i>Osmanya</i>, <i>Phags_Pa</i>,
19080 # <i>Phoenician</i>, <i>Rejang</i>, <i>Runic</i>, <i>Saurashtra</i>,
19081 # <i>Shavian</i>, <i>Sinhala</i>, <i>Sundanese</i>, <i>Syloti_Nagri</i>,
19082 # <i>Syriac</i>, <i>Tagalog</i>, <i>Tagbanwa</i>, <i>Tai_Le</i>,
19083 # <i>Tamil</i>, <i>Telugu</i>, <i>Thaana</i>, <i>Thai</i>, <i>Tibetan</i>,
19084 # <i>Tifinagh</i>, <i>Ugaritic</i>, <i>Vai</i>, and <i>Yi</i>.
19085 # 
19086 #     # Unicode codepoint U+06E9 is named "ARABIC PLACE OF SAJDAH" and
19087 #     # belongs to the Arabic script.
19088 #     /\p{Arabic}/.match("\u06E9") #=> #<MatchData "\u06E9">
19089 # 
19090 # All character properties can be inverted by prefixing their name with a
19091 # caret (<tt>^</tt>).
19092 # 
19093 #     # Letter 'A' is not in the Unicode Ll (Letter; Lowercase) category, so
19094 #     # this match succeeds
19095 #     /\p{^Ll}/.match("A") #=> #<MatchData "A">
19096 # 
19097 # == Anchors
19098 # 
19099 # Anchors are metacharacter that match the zero-width positions between
19100 # characters, <i>anchoring</i> the match to a specific position.
19101 # 
19102 # * <tt>^</tt> - Matches beginning of line
19103 # * <tt>$</tt> - Matches end of line
19104 # * <tt>\A</tt> - Matches beginning of string.
19105 # * <tt>\Z</tt> - Matches end of string. If string ends with a newline,
19106 #   it matches just before newline
19107 # * <tt>\z</tt> - Matches end of string
19108 # * <tt>\G</tt> - Matches point where last match finished
19109 # * <tt>\b</tt> - Matches word boundaries when outside brackets;
19110 #   backspace (0x08) when inside brackets
19111 # * <tt>\B</tt> - Matches non-word boundaries
19112 # * <tt>(?=</tt><i>pat</i><tt>)</tt> - <i>Positive lookahead</i> assertion:
19113 #   ensures that the following characters match <i>pat</i>, but doesn't
19114 #   include those characters in the matched text
19115 # * <tt>(?!</tt><i>pat</i><tt>)</tt> - <i>Negative lookahead</i> assertion:
19116 #   ensures that the following characters do not match <i>pat</i>, but
19117 #   doesn't include those characters in the matched text
19118 # * <tt>(?<=</tt><i>pat</i><tt>)</tt> - <i>Positive lookbehind</i>
19119 #   assertion: ensures that the preceding characters match <i>pat</i>, but
19120 #   doesn't include those characters in the matched text
19121 # * <tt>(?<!</tt><i>pat</i><tt>)</tt> - <i>Negative lookbehind</i>
19122 #   assertion: ensures that the preceding characters do not match
19123 #   <i>pat</i>, but doesn't include those characters in the matched text
19124 # 
19125 #     # If a pattern isn't anchored it can begin at any point in the string
19126 #     /real/.match("surrealist") #=> #<MatchData "real">
19127 #     # Anchoring the pattern to the beginning of the string forces the
19128 #     # match to start there. 'real' doesn't occur at the beginning of the
19129 #     # string, so now the match fails
19130 #     /\Areal/.match("surrealist") #=> nil
19131 #     # The match below fails because although 'Demand' contains 'and', the
19132 #     pattern does not occur at a word boundary.
19133 #     /\band/.match("Demand")
19134 #     # Whereas in the following example 'and' has been anchored to a
19135 #     # non-word boundary so instead of matching the first 'and' it matches
19136 #     # from the fourth letter of 'demand' instead
19137 #     /\Band.+/.match("Supply and demand curve") #=> #<MatchData "and curve">
19138 #     # The pattern below uses positive lookahead and positive lookbehind to
19139 #     # match text appearing in <b></b> tags without including the tags in the
19140 #     # match
19141 #     /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>")
19142 #         #=> #<MatchData "bold">
19143 # 
19144 # == Options
19145 # 
19146 # The end delimiter for a regexp can be followed by one or more single-letter
19147 # options which control how the pattern can match.
19148 # 
19149 # * <tt>/pat/i</tt> - Ignore case
19150 # * <tt>/pat/m</tt> - Treat a newline as a character matched by <tt>.</tt>
19151 # * <tt>/pat/x</tt> - Ignore whitespace and comments in the pattern
19152 # * <tt>/pat/o</tt> - Perform <tt>#{}</tt> interpolation only once
19153 # 
19154 # <tt>i</tt>, <tt>m</tt>, and <tt>x</tt> can also be applied on the
19155 # subexpression level with the
19156 # <tt>(?</tt><i>on</i><tt>-</tt><i>off</i><tt>)</tt> construct, which
19157 # enables options <i>on</i>, and disables options <i>off</i> for the
19158 # expression enclosed by the parentheses.
19159 # 
19160 #     /a(?i:b)c/.match('aBc') #=> #<MatchData "aBc">
19161 #     /a(?i:b)c/.match('abc') #=> #<MatchData "abc">
19162 # 
19163 # Options may also be used with <tt>Regexp.new</tt>:
19164 # 
19165 #     Regexp.new("abc", Regexp::IGNORECASE)                     #=> /abc/i
19166 #     Regexp.new("abc", Regexp::MULTILINE)                      #=> /abc/m
19167 #     Regexp.new("abc # Comment", Regexp::EXTENDED)             #=> /abc # Comment/x
19168 #     Regexp.new("abc", Regexp::IGNORECASE | Regexp::MULTILINE) #=> /abc/mi
19169 # 
19170 # == Free-Spacing Mode and Comments
19171 # 
19172 # As mentioned above, the <tt>x</tt> option enables <i>free-spacing</i>
19173 # mode. Literal white space inside the pattern is ignored, and the
19174 # octothorpe (<tt>#</tt>) character introduces a comment until the end of
19175 # the line. This allows the components of the pattern to be organised in a
19176 # potentially more readable fashion.
19177 # 
19178 #     # A contrived pattern to match a number with optional decimal places
19179 #     float_pat = /\A
19180 #         [[:digit:]]+ # 1 or more digits before the decimal point
19181 #         (\.          # Decimal point
19182 #             [[:digit:]]+ # 1 or more digits after the decimal point
19183 #         )? # The decimal point and following digits are optional
19184 #     \Z/x
19185 #     float_pat.match('3.14') #=> #<MatchData "3.14" 1:".14">
19186 # 
19187 # *Note*: To match whitespace in an <tt>x</tt> pattern use an escape such as
19188 # <tt>\s</tt> or <tt>\p{Space}</tt>.
19189 # 
19190 # Comments can be included in a non-<tt>x</tt> pattern with the
19191 # <tt>(?#</tt><i>comment</i><tt>)</tt> construct, where <i>comment</i> is
19192 # arbitrary text ignored by the regexp engine.
19193 # 
19194 # == Encoding
19195 # 
19196 # Regular expressions are assumed to use the source encoding. This can be
19197 # overridden with one of the following modifiers.
19198 # 
19199 # * <tt>/</tt><i>pat</i><tt>/u</tt> - UTF-8
19200 # * <tt>/</tt><i>pat</i><tt>/e</tt> - EUC-JP
19201 # * <tt>/</tt><i>pat</i><tt>/s</tt> - Windows-31J
19202 # * <tt>/</tt><i>pat</i><tt>/n</tt> - ASCII-8BIT
19203 # 
19204 # A regexp can be matched against a string when they either share an
19205 # encoding, or the regexp's encoding is _US-ASCII_ and the string's encoding
19206 # is ASCII-compatible.
19207 # 
19208 # If a match between incompatible encodings is attempted an
19209 # <tt>Encoding::CompatibilityError</tt> exception is raised.
19210 # 
19211 # The <tt>Regexp#fixed_encoding?</tt> predicate indicates whether the regexp
19212 # has a <i>fixed</i> encoding, that is one incompatible with ASCII. A
19213 # regexp's encoding can be explicitly fixed by supplying
19214 # <tt>Regexp::FIXEDENCODING</tt> as the second argument of
19215 # <tt>Regexp.new</tt>:
19216 # 
19217 #     r = Regexp.new("a".force_encoding("iso-8859-1"),Regexp::FIXEDENCODING)
19218 #     r =~"a\u3042"
19219 #        #=> Encoding::CompatibilityError: incompatible encoding regexp match
19220 #             (ISO-8859-1 regexp with UTF-8 string)
19221 # 
19222 # == Special global variables
19223 # 
19224 # Pattern matching sets some global variables :
19225 # * <tt>$~</tt> is equivalent to Regexp.last_match;
19226 # * <tt>$&</tt> contains the complete matched text;
19227 # * <tt>$`</tt> contains string before match;
19228 # * <tt>$'</tt> contains string after match;
19229 # * <tt>$1</tt>, <tt>$2</tt> and so on contain text matching first, second, etc
19230 #   capture group;
19231 # * <tt>$+</tt> contains last capture group.
19232 # 
19233 # Example:
19234 # 
19235 #     m = /s(\w{2}).*(c)/.match('haystack') #=> #<MatchData "stac" 1:"ta" 2:"c">
19236 #     $~                                    #=> #<MatchData "stac" 1:"ta" 2:"c">
19237 #     Regexp.latch_match                    #=> #<MatchData "stac" 1:"ta" 2:"c">
19238 # 
19239 #     $&      #=> "stac"
19240 #             # same as m[0]
19241 #     $`      #=> "hay"
19242 #             # same as m.pre_match
19243 #     $'      #=> "k"
19244 #             # same as m.post_match
19245 #     $1      #=> "ta"
19246 #             # same as m[1]
19247 #     $2      #=> "c"
19248 #             # same as m[2]
19249 #     $3      #=> nil
19250 #             # no third group in pattern
19251 #     $+      #=> "c"
19252 #             # same as m[-1]
19253 # 
19254 # These global variables are thread-local and method-local variables.
19255 # 
19256 # == Performance
19257 # 
19258 # Certain pathological combinations of constructs can lead to abysmally bad
19259 # performance.
19260 # 
19261 # Consider a string of 25 <i>a</i>s, a <i>d</i>, 4 <i>a</i>s, and a
19262 # <i>c</i>.
19263 # 
19264 #     s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
19265 #     #=> "aaaaaaaaaaaaaaaaaaaaaaaaadaaaac"
19266 # 
19267 # The following patterns match instantly as you would expect:
19268 # 
19269 #     /(b|a)/ =~ s #=> 0
19270 #     /(b|a+)/ =~ s #=> 0
19271 #     /(b|a+)*\/ =~ s #=> 0
19272 # 
19273 # However, the following pattern takes appreciably longer:
19274 # 
19275 #     /(b|a+)*c/ =~ s #=> 26
19276 # 
19277 # This happens because an atom in the regexp is quantified by both an
19278 # immediate <tt>+</tt> and an enclosing <tt>*</tt> with nothing to
19279 # differentiate which is in control of any particular character. The
19280 # nondeterminism that results produces super-linear performance. (Consult
19281 # <i>Mastering Regular Expressions</i> (3rd ed.), pp 222, by
19282 # <i>Jeffery Friedl</i>, for an in-depth analysis). This particular case
19283 # can be fixed by use of atomic grouping, which prevents the unnecessary
19284 # backtracking:
19285 # 
19286 #     (start = Time.now) && /(b|a+)*c/ =~ s && (Time.now - start)
19287 #        #=> 24.702736882
19288 #     (start = Time.now) && /(?>b|a+)*c/ =~ s && (Time.now - start)
19289 #        #=> 0.000166571
19290 # 
19291 # A similar case is typified by the following example, which takes
19292 # approximately 60 seconds to execute for me:
19293 # 
19294 #     # Match a string of 29 <i>a</i>s against a pattern of 29 optional
19295 #     # <i>a</i>s followed by 29 mandatory <i>a</i>s.
19296 #     Regexp.new('a?' * 29 + 'a' * 29) =~ 'a' * 29
19297 # 
19298 # The 29 optional <i>a</i>s match the string, but this prevents the 29
19299 # mandatory <i>a</i>s that follow from matching. Ruby must then backtrack
19300 # repeatedly so as to satisfy as many of the optional matches as it can
19301 # while still matching the mandatory 29. It is plain to us that none of the
19302 # optional matches can succeed, but this fact unfortunately eludes Ruby.
19303 # 
19304 # The best way to improve performance is to significantly reduce the amount of
19305 # backtracking needed.  For this case, instead of individually matching 29
19306 # optional <i>a</i>s, a range of optional <i>a</i>s can be matched all at once
19307 # with <i>a{0,29}</i>:
19308 # 
19309 #     Regexp.new('a{0,29}' + 'a' * 29) =~ 'a' * 29
19310 class Regexp < Object
19311 ##
19312 # Escapes any characters that would have special meaning in a regular
19313 # expression. Returns a new escaped string, or self if no characters are
19314 # escaped.  For any string,
19315 # <code>Regexp.new(Regexp.escape(<i>str</i>))=~<i>str</i></code> will be true.
19316 # 
19317 #    Regexp.escape('\*?{}.')   #=> \\\*\?\{\}\.
19318 def self.escape(str); ''; end
19319 ##
19320 # Escapes any characters that would have special meaning in a regular
19321 # expression. Returns a new escaped string, or self if no characters are
19322 # escaped.  For any string,
19323 # <code>Regexp.new(Regexp.escape(<i>str</i>))=~<i>str</i></code> will be true.
19324 # 
19325 #    Regexp.escape('\*?{}.')   #=> \\\*\?\{\}\.
19326 def self.quote(str); ''; end
19327 ##
19328 # Return a <code>Regexp</code> object that is the union of the given
19329 # <em>pattern</em>s, i.e., will match any of its parts. The <em>pattern</em>s
19330 # can be Regexp objects, in which case their options will be preserved, or
19331 # Strings. If no patterns are given, returns <code>/(?!)/</code>.
19332 # The behavior is unspecified if any given <em>pattern</em> contains capture.
19333 # 
19334 #    Regexp.union                         #=> /(?!)/
19335 #    Regexp.union("penzance")             #=> /penzance/
19336 #    Regexp.union("a+b*c")                #=> /a\+b\*c/
19337 #    Regexp.union("skiing", "sledding")   #=> /skiing|sledding/
19338 #    Regexp.union(["skiing", "sledding"]) #=> /skiing|sledding/
19339 #    Regexp.union(/dogs/, /cats/i)        #=> /(?-mix:dogs)|(?i-mx:cats)/
19340 def self.union(); //; end
19341 ##
19342 # The first form returns the MatchData object generated by the
19343 # last successful pattern match.  Equivalent to reading the special global
19344 # variable <code>$~</code> (see Special global variables in Regexp for
19345 # details).
19346 # 
19347 # The second form returns the <i>n</i>th field in this MatchData object.
19348 # _n_ can be a string or symbol to reference a named capture.
19349 # 
19350 # Note that the last_match is local to the thread and method scope of the
19351 # method that did the pattern match.
19352 # 
19353 #    /c(.)t/ =~ 'cat'        #=> 0
19354 #    Regexp.last_match       #=> #<MatchData "cat" 1:"a">
19355 #    Regexp.last_match(0)    #=> "cat"
19356 #    Regexp.last_match(1)    #=> "a"
19357 #    Regexp.last_match(2)    #=> nil
19358 # 
19359 #    /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "var = val"
19360 #    Regexp.last_match       #=> #<MatchData "var = val" lhs:"var" rhs:"val">
19361 #    Regexp.last_match(:lhs) #=> "var"
19362 #    Regexp.last_match(:rhs) #=> "val"
19363 def self.last_match; ''; end
19364 ##
19365 # Try to convert <i>obj</i> into a Regexp, using to_regexp method.
19366 # Returns converted regexp or nil if <i>obj</i> cannot be converted
19367 # for any reason.
19368 # 
19369 #    Regexp.try_convert(/re/)         #=> /re/
19370 #    Regexp.try_convert("re")         #=> nil
19371 # 
19372 #    o = Object.new
19373 #    Regexp.try_convert(o)            #=> nil
19374 #    def o.to_regexp() /foo/ end
19375 #    Regexp.try_convert(o)            #=> /foo/
19376 def self.try_convert(obj); // || nil; end
19377 ##
19378 # Constructs a new regular expression from +pattern+, which can be either a
19379 # String or a Regexp (in which case that regexp's options are propagated),
19380 # and new options may not be specified (a change as of Ruby 1.8).
19381 # 
19382 # If +options+ is a Fixnum, it should be one or more of the constants
19383 # Regexp::EXTENDED, Regexp::IGNORECASE, and Regexp::MULTILINE,
19384 # <em>or</em>-ed together.  Otherwise, if +options+ is not
19385 # +nil+ or +false+, the regexp will be case insensitive.
19386 # 
19387 # When the +kcode+ parameter is `n' or `N' sets the regexp no encoding.
19388 # It means that the regexp is for binary strings.
19389 # 
19390 #   r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
19391 #   r2 = Regexp.new('cat', true)     #=> /cat/i
19392 #   r3 = Regexp.new(r2)              #=> /cat/i
19393 #   r4 = Regexp.new('dog', Regexp::EXTENDED | Regexp::IGNORECASE) #=> /dog/ix
19394 def self.new(string, options=0, kcode=0); end
19395 ##
19396 # Constructs a new regular expression from +pattern+, which can be either a
19397 # String or a Regexp (in which case that regexp's options are propagated),
19398 # and new options may not be specified (a change as of Ruby 1.8).
19399 # 
19400 # If +options+ is a Fixnum, it should be one or more of the constants
19401 # Regexp::EXTENDED, Regexp::IGNORECASE, and Regexp::MULTILINE,
19402 # <em>or</em>-ed together.  Otherwise, if +options+ is not
19403 # +nil+ or +false+, the regexp will be case insensitive.
19404 # 
19405 # When the +kcode+ parameter is `n' or `N' sets the regexp no encoding.
19406 # It means that the regexp is for binary strings.
19407 # 
19408 #   r1 = Regexp.new('^a-z+:\\s+\w+') #=> /^a-z+:\s+\w+/
19409 #   r2 = Regexp.new('cat', true)     #=> /cat/i
19410 #   r3 = Regexp.new(r2)              #=> /cat/i
19411 #   r4 = Regexp.new('dog', Regexp::EXTENDED | Regexp::IGNORECASE) #=> /dog/ix
19412 def self.compile(string, options=0, kcode=0); //; end
19413 ##
19414 # Produce a hash based on the text and options of this regular expression.
19415 def hash; 0; end
19416 ##
19417 # Equality---Two regexps are equal if their patterns are identical, they have
19418 # the same character set code, and their <code>casefold?</code> values are the
19419 # same.
19420 # 
19421 #    /abc/  == /abc/x   #=> false
19422 #    /abc/  == /abc/i   #=> false
19423 #    /abc/  == /abc/u   #=> false
19424 #    /abc/u == /abc/n   #=> false
19425 def eql?; true || false; end
19426 ##
19427 # Equality---Two regexps are equal if their patterns are identical, they have
19428 # the same character set code, and their <code>casefold?</code> values are the
19429 # same.
19430 # 
19431 #    /abc/  == /abc/x   #=> false
19432 #    /abc/  == /abc/i   #=> false
19433 #    /abc/  == /abc/u   #=> false
19434 #    /abc/u == /abc/n   #=> false
19435 def ==; true || false; end
19436 ##
19437 # Match---Matches <i>rxp</i> against <i>str</i>.
19438 # 
19439 #    /at/ =~ "input data"   #=> 7
19440 #    /ax/ =~ "input data"   #=> nil
19441 # 
19442 # If <code>=~</code> is used with a regexp literal with named captures,
19443 # captured strings (or nil) is assigned to local variables named by
19444 # the capture names.
19445 # 
19446 #    /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "  x = y  "
19447 #    p lhs    #=> "x"
19448 #    p rhs    #=> "y"
19449 # 
19450 # If it is not matched, nil is assigned for the variables.
19451 # 
19452 #    /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ "  x = "
19453 #    p lhs    #=> nil
19454 #    p rhs    #=> nil
19455 # 
19456 # This assignment is implemented in the Ruby parser.
19457 # The parser detects 'regexp-literal =~ expression' for the assignment.
19458 # The regexp must be a literal without interpolation and placed at left hand side.
19459 # 
19460 # The assignment does not occur if the regexp is not a literal.
19461 # 
19462 #    re = /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/
19463 #    re =~ "  x = y  "
19464 #    p lhs    # undefined local variable
19465 #    p rhs    # undefined local variable
19466 # 
19467 # A regexp interpolation, <code>#{}</code>, also disables
19468 # the assignment.
19469 # 
19470 #    rhs_pat = /(?<rhs>\w+)/
19471 #    /(?<lhs>\w+)\s*=\s*#{rhs_pat}/ =~ "x = y"
19472 #    p lhs    # undefined local variable
19473 # 
19474 # The assignment does not occur if the regexp is placed at the right hand side.
19475 # 
19476 #   "  x = y  " =~ /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/
19477 #   p lhs, rhs # undefined local variable
19478 def =~; 1 || nil; end
19479 ##
19480 # Case Equality---Used in case statements.
19481 # 
19482 #    a = "HELLO"
19483 #    case a
19484 #    when /^[a-z]*$/; print "Lower case\n"
19485 #    when /^[A-Z]*$/; print "Upper case\n"
19486 #    else;            print "Mixed case\n"
19487 #    end
19488 #    #=> "Upper case"
19489 # 
19490 # Following a regular expression literal with the #=== operator allows you to
19491 # compare against a String.
19492 # 
19493 #     /^[a-z]*$/ === "HELLO" #=> false
19494 #     /^[A-Z]*$/ === "HELLO" #=> true
19495 def ===; true || false; end
19496 ##
19497 # Match---Matches <i>rxp</i> against the contents of <code>$_</code>.
19498 # Equivalent to <code><i>rxp</i> =~ $_</code>.
19499 # 
19500 #    $_ = "input data"
19501 #    ~ /at/   #=> 7
19502 def ~; 1 || nil; end
19503 ##
19504 # Returns a <code>MatchData</code> object describing the match, or
19505 # <code>nil</code> if there was no match. This is equivalent to retrieving the
19506 # value of the special variable <code>$~</code> following a normal match.
19507 # If the second parameter is present, it specifies the position in the string
19508 # to begin the search.
19509 # 
19510 #    /(.)(.)(.)/.match("abc")[2]   #=> "b"
19511 #    /(.)(.)/.match("abc", 1)[2]   #=> "c"
19512 # 
19513 # If a block is given, invoke the block with MatchData if match succeed, so
19514 # that you can write
19515 # 
19516 #    pat.match(str) {|m| ...}
19517 # 
19518 # instead of
19519 # 
19520 #    if m = pat.match(str)
19521 #      ...
19522 #    end
19523 # 
19524 # The return value is a value from block execution in this case.
19525 def match(str); MatchData.new || nil; end
19526 ##
19527 # Returns a string containing the regular expression and its options (using the
19528 # <code>(?opts:source)</code> notation. This string can be fed back in to
19529 # <code>Regexp::new</code> to a regular expression with the same semantics as
19530 # the original. (However, <code>Regexp#==</code> may not return true when
19531 # comparing the two, as the source of the regular expression itself may
19532 # differ, as the example shows).  <code>Regexp#inspect</code> produces a
19533 # generally more readable version of <i>rxp</i>.
19534 # 
19535 #     r1 = /ab+c/ix           #=> /ab+c/ix
19536 #     s1 = r1.to_s            #=> "(?ix-m:ab+c)"
19537 #     r2 = Regexp.new(s1)     #=> /(?ix-m:ab+c)/
19538 #     r1 == r2                #=> false
19539 #     r1.source               #=> "ab+c"
19540 #     r2.source               #=> "(?ix-m:ab+c)"
19541 def to_s; ''; end
19542 ##
19543 # Produce a nicely formatted string-version of _rxp_. Perhaps surprisingly,
19544 # <code>#inspect</code> actually produces the more natural version of
19545 # the string than <code>#to_s</code>.
19546 # 
19547 #      /ab+c/ix.inspect        #=> "/ab+c/ix"
19548 def inspect; ''; end
19549 ##
19550 # Returns the original string of the pattern.
19551 # 
19552 #     /ab+c/ix.source #=> "ab+c"
19553 # 
19554 # Note that escape sequences are retained as is.
19555 # 
19556 #    /\x20\+/.source  #=> "\\x20\\+"
19557 def source; ''; end
19558 ##
19559 # Returns the value of the case-insensitive flag.
19560 # 
19561 #     /a/.casefold?           #=> false
19562 #     /a/i.casefold?          #=> true
19563 #     /(?i:a)/.casefold?      #=> false
19564 def casefold?; true || false; end
19565 ##
19566 # Returns the set of bits corresponding to the options used when creating this
19567 # Regexp (see <code>Regexp::new</code> for details. Note that additional bits
19568 # may be set in the returned options: these are used internally by the regular
19569 # expression code. These extra bits are ignored if the options are passed to
19570 # <code>Regexp::new</code>.
19571 # 
19572 #    Regexp::IGNORECASE                  #=> 1
19573 #    Regexp::EXTENDED                    #=> 2
19574 #    Regexp::MULTILINE                   #=> 4
19575 # 
19576 #    /cat/.options                       #=> 0
19577 #    /cat/ix.options                     #=> 3
19578 #    Regexp.new('cat', true).options     #=> 1
19579 #    /\xa1\xa2/e.options                 #=> 16
19580 # 
19581 #    r = /cat/ix
19582 #    Regexp.new(r.source, r.options)     #=> /cat/ix
19583 def options; 0; end
19584 ##
19585 # Returns the Encoding object that represents the encoding of obj.
19586 def encoding; Encoding.new; end
19587 ##
19588 # Returns false if rxp is applicable to
19589 # a string with any ASCII compatible encoding.
19590 # Returns true otherwise.
19591 # 
19592 #     r = /a/
19593 #     r.fixed_encoding?                               #=> false
19594 #     r =~ "\u{6666} a"                               #=> 2
19595 #     r =~ "\xa1\xa2 a".force_encoding("euc-jp")      #=> 2
19596 #     r =~ "abc".force_encoding("euc-jp")             #=> 0
19597 # 
19598 #     r = /a/u
19599 #     r.fixed_encoding?                               #=> true
19600 #     r.encoding                                      #=> #<Encoding:UTF-8>
19601 #     r =~ "\u{6666} a"                               #=> 2
19602 #     r =~ "\xa1\xa2".force_encoding("euc-jp")        #=> ArgumentError
19603 #     r =~ "abc".force_encoding("euc-jp")             #=> 0
19604 # 
19605 #     r = /\u{6666}/
19606 #     r.fixed_encoding?                               #=> true
19607 #     r.encoding                                      #=> #<Encoding:UTF-8>
19608 #     r =~ "\u{6666} a"                               #=> 0
19609 #     r =~ "\xa1\xa2".force_encoding("euc-jp")        #=> ArgumentError
19610 #     r =~ "abc".force_encoding("euc-jp")             #=> nil
19611 def fixed_encoding?; true || false; end
19612 ##
19613 # Returns a list of names of captures as an array of strings.
19614 # 
19615 #     /(?<foo>.)(?<bar>.)(?<baz>.)/.names
19616 #     #=> ["foo", "bar", "baz"]
19617 # 
19618 #     /(?<foo>.)(?<foo>.)/.names
19619 #     #=> ["foo"]
19620 # 
19621 #     /(.)(.)/.names
19622 #     #=> []
19623 def names; []; end
19624 ##
19625 # Returns a hash representing information about named captures of <i>rxp</i>.
19626 # 
19627 # A key of the hash is a name of the named captures.
19628 # A value of the hash is an array which is list of indexes of corresponding
19629 # named captures.
19630 # 
19631 #    /(?<foo>.)(?<bar>.)/.named_captures
19632 #    #=> {"foo"=>[1], "bar"=>[2]}
19633 # 
19634 #    /(?<foo>.)(?<foo>.)/.named_captures
19635 #    #=> {"foo"=>[1, 2]}
19636 # 
19637 # If there are no named captures, an empty hash is returned.
19638 # 
19639 #    /(.)(.)/.named_captures
19640 #    #=> {}
19641 def named_captures; {}; end
19642 end
19643 
19644 ##
19645 # <code>MatchData</code> is the type of the special variable <code>$~</code>,
19646 # and is the type of the object returned by <code>Regexp#match</code> and
19647 # <code>Regexp.last_match</code>. It encapsulates all the results of a pattern
19648 # match, results normally accessed through the special variables
19649 # <code>$&</code>, <code>$'</code>, <code>$`</code>, <code>$1</code>,
19650 # <code>$2</code>, and so on.
19651 class MatchData < Object
19652 ##
19653 # Returns the regexp.
19654 # 
19655 #     m = /a.*b/.match("abc")
19656 #     m.regexp #=> /a.*b/
19657 def regexp; //; end
19658 ##
19659 # Returns a list of names of captures as an array of strings.
19660 # It is same as mtch.regexp.names.
19661 # 
19662 #     /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").names
19663 #     #=> ["foo", "bar", "baz"]
19664 # 
19665 #     m = /(?<x>.)(?<y>.)?/.match("a") #=> #<MatchData "a" x:"a" y:nil>
19666 #     m.names                          #=> ["x", "y"]
19667 def names; []; end
19668 ##
19669 # Returns the number of elements in the match array.
19670 # 
19671 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19672 #    m.length   #=> 5
19673 #    m.size     #=> 5
19674 def length; 0; end
19675 ##
19676 # Returns the number of elements in the match array.
19677 # 
19678 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19679 #    m.length   #=> 5
19680 #    m.size     #=> 5
19681 def size; 0; end
19682 ##
19683 # Returns a two-element array containing the beginning and ending offsets of
19684 # the <em>n</em>th match.
19685 # <em>n</em> can be a string or symbol to reference a named capture.
19686 # 
19687 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19688 #    m.offset(0)      #=> [1, 7]
19689 #    m.offset(4)      #=> [6, 7]
19690 # 
19691 #    m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
19692 #    p m.offset(:foo) #=> [0, 1]
19693 #    p m.offset(:bar) #=> [2, 3]
19694 def offset(n); []; end
19695 ##
19696 # Returns the offset of the start of the <em>n</em>th element of the match
19697 # array in the string.
19698 # <em>n</em> can be a string or symbol to reference a named capture.
19699 # 
19700 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19701 #    m.begin(0)       #=> 1
19702 #    m.begin(2)       #=> 2
19703 # 
19704 #    m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
19705 #    p m.begin(:foo)  #=> 0
19706 #    p m.begin(:bar)  #=> 2
19707 def begin(n); 0; end
19708 ##
19709 # Returns the offset of the character immediately following the end of the
19710 # <em>n</em>th element of the match array in the string.
19711 # <em>n</em> can be a string or symbol to reference a named capture.
19712 # 
19713 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19714 #    m.end(0)         #=> 7
19715 #    m.end(2)         #=> 3
19716 # 
19717 #    m = /(?<foo>.)(.)(?<bar>.)/.match("hoge")
19718 #    p m.end(:foo)    #=> 1
19719 #    p m.end(:bar)    #=> 3
19720 def end(n); 0; end
19721 ##
19722 # Returns the array of matches.
19723 # 
19724 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19725 #    m.to_a   #=> ["HX1138", "H", "X", "113", "8"]
19726 # 
19727 # Because <code>to_a</code> is called when expanding
19728 # <code>*</code><em>variable</em>, there's a useful assignment
19729 # shortcut for extracting matched fields. This is slightly slower than
19730 # accessing the fields directly (as an intermediate array is
19731 # generated).
19732 # 
19733 #    all,f1,f2,f3 = *(/(.)(.)(\d+)(\d)/.match("THX1138."))
19734 #    all   #=> "HX1138"
19735 #    f1    #=> "H"
19736 #    f2    #=> "X"
19737 #    f3    #=> "113"
19738 def to_a; []; end
19739 ##
19740 # Match Reference -- <code>MatchData</code> acts as an array, and may be
19741 # accessed using the normal array indexing techniques.  <code>mtch[0]</code>
19742 # is equivalent to the special variable <code>$&</code>, and returns the
19743 # entire matched string.  <code>mtch[1]</code>, <code>mtch[2]</code>, and so
19744 # on return the values of the matched backreferences (portions of the
19745 # pattern between parentheses).
19746 # 
19747 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19748 #    m          #=> #<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">
19749 #    m[0]       #=> "HX1138"
19750 #    m[1, 2]    #=> ["H", "X"]
19751 #    m[1..3]    #=> ["H", "X", "113"]
19752 #    m[-3, 2]   #=> ["X", "113"]
19753 # 
19754 #    m = /(?<foo>a+)b/.match("ccaaab")
19755 #    m          #=> #<MatchData "aaab" foo:"aaa">
19756 #    m["foo"]   #=> "aaa"
19757 #    m[:foo]    #=> "aaa"
19758 def []; '' || nil; end
19759 ##
19760 # Returns the array of captures; equivalent to <code>mtch.to_a[1..-1]</code>.
19761 # 
19762 #    f1,f2,f3,f4 = /(.)(.)(\d+)(\d)/.match("THX1138.").captures
19763 #    f1    #=> "H"
19764 #    f2    #=> "X"
19765 #    f3    #=> "113"
19766 #    f4    #=> "8"
19767 def captures; []; end
19768 ##
19769 # Uses each <i>index</i> to access the matching values, returning an array of
19770 # the corresponding matches.
19771 # 
19772 #    m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
19773 #    m.to_a               #=> ["HX1138", "H", "X", "113", "8"]
19774 #    m.values_at(0, 2, -2)   #=> ["HX1138", "X", "113"]
19775 def values_at(); []; end
19776 ##
19777 # Returns the portion of the original string before the current match.
19778 # Equivalent to the special variable <code>$`</code>.
19779 # 
19780 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19781 #    m.pre_match   #=> "T"
19782 def pre_match; ''; end
19783 ##
19784 # Returns the portion of the original string after the current match.
19785 # Equivalent to the special variable <code>$'</code>.
19786 # 
19787 #    m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
19788 #    m.post_match   #=> ": The Movie"
19789 def post_match; ''; end
19790 ##
19791 # Returns the entire matched string.
19792 # 
19793 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19794 #    m.to_s   #=> "HX1138"
19795 def to_s; ''; end
19796 ##
19797 # Returns a printable version of <i>mtch</i>.
19798 # 
19799 #     puts /.$/.match("foo").inspect
19800 #     #=> #<MatchData "o">
19801 # 
19802 #     puts /(.)(.)(.)/.match("foo").inspect
19803 #     #=> #<MatchData "foo" 1:"f" 2:"o" 3:"o">
19804 # 
19805 #     puts /(.)(.)?(.)/.match("fo").inspect
19806 #     #=> #<MatchData "fo" 1:"f" 2:nil 3:"o">
19807 # 
19808 #     puts /(?<foo>.)(?<bar>.)(?<baz>.)/.match("hoge").inspect
19809 #     #=> #<MatchData "hog" foo:"h" bar:"o" baz:"g">
19810 def inspect; ''; end
19811 ##
19812 # Returns a frozen copy of the string passed in to <code>match</code>.
19813 # 
19814 #    m = /(.)(.)(\d+)(\d)/.match("THX1138.")
19815 #    m.string   #=> "THX1138."
19816 def string; ''; end
19817 ##
19818 # Produce a hash based on the target string, regexp and matched
19819 # positions of this matchdata.
19820 def hash; 0; end
19821 ##
19822 # Equality---Two matchdata are equal if their target strings,
19823 # patterns, and matched positions are identical.
19824 def eql?; true || false; end
19825 ##
19826 # Equality---Two matchdata are equal if their target strings,
19827 # patterns, and matched positions are identical.
19828 def ==; true || false; end
19829 end
19830 
19831 ##
19832 # This is a recommended base class for C extensions using Data_Make_Struct
19833 # or Data_Wrap_Struct, see README.EXT for details.
19834 class Data < Object
19835 end
19836 
19837 ##
19838 # The global value <code>true</code> is the only instance of class
19839 # <code>TrueClass</code> and represents a logically true value in
19840 # boolean expressions. The class provides operators allowing
19841 # <code>true</code> to be used in logical expressions.
19842 class TrueClass < Object
19843 ##
19844 # The string representation of <code>true</code> is "true".
19845 def to_s; true; end
19846 ##
19847 # And---Returns <code>false</code> if <i>obj</i> is
19848 # <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
19849 def &; true || false; end
19850 ##
19851 # Or---Returns <code>true</code>. As <i>anObject</i> is an argument to
19852 # a method call, it is always evaluated; there is no short-circuit
19853 # evaluation in this case.
19854 # 
19855 #    true |  puts("or")
19856 #    true || puts("logical or")
19857 # 
19858 # <em>produces:</em>
19859 # 
19860 #    or
19861 def |; true; end
19862 ##
19863 # Exclusive Or---Returns <code>true</code> if <i>obj</i> is
19864 # <code>nil</code> or <code>false</code>, <code>false</code>
19865 # otherwise.
19866 def ^; Object.new; end
19867 end
19868 
19869 ##
19870 # The global value <code>false</code> is the only instance of class
19871 # <code>FalseClass</code> and represents a logically false value in
19872 # boolean expressions. The class provides operators allowing
19873 # <code>false</code> to participate correctly in logical expressions.
19874 class FalseClass < Object
19875 ##
19876 # 'nuf said...
19877 def to_s; false; end
19878 ##
19879 # And---Returns <code>false</code>. <i>obj</i> is always
19880 # evaluated as it is the argument to a method call---there is no
19881 # short-circuit evaluation in this case.
19882 def &; false; end
19883 ##
19884 # Or---Returns <code>false</code> if <i>obj</i> is
19885 # <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
19886 def |; true || false; end
19887 ##
19888 # Exclusive Or---If <i>obj</i> is <code>nil</code> or
19889 # <code>false</code>, returns <code>false</code>; otherwise, returns
19890 # <code>true</code>.
19891 def ^; true || false; end
19892 end
19893 
19894 ##
19895 # ThreadGroup provides a means of keeping track of a number of threads as a
19896 # group.
19897 # 
19898 # A given Thread object can only belong to one ThreadGroup at a time; adding
19899 # a thread to a new group will remove it from any previous group.
19900 # 
19901 # Newly created threads belong to the same group as the thread from which they
19902 # were created.
19903 class ThreadGroup < Object
19904 ##
19905 # Returns an array of all existing Thread objects that belong to this group.
19906 # 
19907 #    ThreadGroup::Default.list   #=> [#<Thread:0x401bdf4c run>]
19908 def list; []; end
19909 ##
19910 # Prevents threads from being added to or removed from the receiving
19911 # ThreadGroup.
19912 # 
19913 # New threads can still be started in an enclosed ThreadGroup.
19914 # 
19915 #    ThreadGroup::Default.enclose        #=> #<ThreadGroup:0x4029d914>
19916 #    thr = Thread::new { Thread.stop }   #=> #<Thread:0x402a7210 sleep>
19917 #    tg = ThreadGroup::new               #=> #<ThreadGroup:0x402752d4>
19918 #    tg.add thr
19919 #    #=> ThreadError: can't move from the enclosed thread group
19920 def enclose; ThreadGroup.new; end
19921 ##
19922 # Returns +true+ if the +thgrp+ is enclosed. See also ThreadGroup#enclose.
19923 def enclosed?; true || false; end
19924 ##
19925 # Adds the given +thread+ to this group, removing it from any other
19926 # group to which it may have previously been a member.
19927 # 
19928 #    puts "Initial group is #{ThreadGroup::Default.list}"
19929 #    tg = ThreadGroup.new
19930 #    t1 = Thread.new { sleep }
19931 #    t2 = Thread.new { sleep }
19932 #    puts "t1 is #{t1}"
19933 #    puts "t2 is #{t2}"
19934 #    tg.add(t1)
19935 #    puts "Initial group now #{ThreadGroup::Default.list}"
19936 #    puts "tg group now #{tg.list}"
19937 # 
19938 # This will produce:
19939 # 
19940 #    Initial group is #<Thread:0x401bdf4c>
19941 #    t1 is #<Thread:0x401b3c90>
19942 #    t2 is #<Thread:0x401b3c18>
19943 #    Initial group now #<Thread:0x401b3c18>#<Thread:0x401bdf4c>
19944 #    tg group now #<Thread:0x401b3c90>
19945 def add(thread); ThreadGroup.new; end
19946 end
19947 
19948 ##
19949 # Mutex implements a simple semaphore that can be used to coordinate access to
19950 # shared data from multiple concurrent threads.
19951 # 
19952 # Example:
19953 # 
19954 #   require 'thread'
19955 #   semaphore = Mutex.new
19956 # 
19957 #   a = Thread.new {
19958 #     semaphore.synchronize {
19959 #       # access shared resource
19960 #     }
19961 #   }
19962 # 
19963 #   b = Thread.new {
19964 #     semaphore.synchronize {
19965 #       # access shared resource
19966 #     }
19967 #   }
19968 class Mutex < Object
19969 ##
19970 # Creates a new Mutex
19971 def self.new; end
19972 ##
19973 # Returns +true+ if this lock is currently held by some thread.
19974 def locked?; true || false; end
19975 ##
19976 # Attempts to obtain the lock and returns immediately. Returns +true+ if the
19977 # lock was granted.
19978 def try_lock; true || false; end
19979 ##
19980 # Attempts to grab the lock and waits if it isn't available.
19981 # Raises +ThreadError+ if +mutex+ was locked by the current thread.
19982 def lock; self; end
19983 ##
19984 # Releases the lock.
19985 # Raises +ThreadError+ if +mutex+ wasn't locked by the current thread.
19986 def unlock; self; end
19987 ##
19988 # Releases the lock and sleeps +timeout+ seconds if it is given and
19989 # non-nil or forever.  Raises +ThreadError+ if +mutex+ wasn't locked by
19990 # the current thread.
19991 # 
19992 # Note that this method can wakeup without explicit Thread#wakeup call.
19993 # For example, receiving signal and so on.
19994 def sleep(timeout = null); 0; end
19995 ##
19996 # Obtains a lock, runs the block, and releases the lock when the block
19997 # completes.  See the example under +Mutex+.
19998 def synchronize(&block); Object.new; end
19999 ##
20000 # Returns +true+ if this lock is currently held by current thread.
20001 # <em>This API is experimental, and subject to change.</em>
20002 def owned?; true || false; end
20003 end
20004 
20005 ##
20006 # Raised when an invalid operation is attempted on a thread.
20007 # 
20008 # For example, when no other thread has been started:
20009 # 
20010 #    Thread.stop
20011 # 
20012 # This will raises the following exception:
20013 # 
20014 #    ThreadError: stopping only thread
20015 #    note: use sleep to stop forever
20016 class ThreadError < StandardError
20017 end
20018 
20019 ##
20020 # A class which allows both internal and external iteration.
20021 # 
20022 # An Enumerator can be created by the following methods.
20023 # - Kernel#to_enum
20024 # - Kernel#enum_for
20025 # - Enumerator.new
20026 # 
20027 # Most methods have two forms: a block form where the contents
20028 # are evaluated for each item in the enumeration, and a non-block form
20029 # which returns a new Enumerator wrapping the iteration.
20030 # 
20031 #   enumerator = %w(one two three).each
20032 #   puts enumerator.class # => Enumerator
20033 # 
20034 #   enumerator.each_with_object("foo") do |item, obj|
20035 #     puts "#{obj}: #{item}"
20036 #   end
20037 # 
20038 #   # foo: one
20039 #   # foo: two
20040 #   # foo: three
20041 # 
20042 #   enum_with_obj = enumerator.each_with_object("foo")
20043 #   puts enum_with_obj.class # => Enumerator
20044 # 
20045 #   enum_with_obj.each do |item, obj|
20046 #     puts "#{obj}: #{item}"
20047 #   end
20048 # 
20049 #   # foo: one
20050 #   # foo: two
20051 #   # foo: three
20052 # 
20053 # This allows you to chain Enumerators together.  For example, you
20054 # can map a list's elements to strings containing the index
20055 # and the element as a string via:
20056 # 
20057 #   puts %w[foo bar baz].map.with_index { |w, i| "#{i}:#{w}" }
20058 #   # => ["0:foo", "1:bar", "2:baz"]
20059 # 
20060 # An Enumerator can also be used as an external iterator.
20061 # For example, Enumerator#next returns the next value of the iterator
20062 # or raises StopIteration if the Enumerator is at the end.
20063 # 
20064 #   e = [1,2,3].each   # returns an enumerator object.
20065 #   puts e.next   # => 1
20066 #   puts e.next   # => 2
20067 #   puts e.next   # => 3
20068 #   puts e.next   # raises StopIteration
20069 # 
20070 # You can use this to implement an internal iterator as follows:
20071 # 
20072 #   def ext_each(e)
20073 #     while true
20074 #       begin
20075 #         vs = e.next_values
20076 #       rescue StopIteration
20077 #         return $!.result
20078 #       end
20079 #       y = yield(*vs)
20080 #       e.feed y
20081 #     end
20082 #   end
20083 # 
20084 #   o = Object.new
20085 # 
20086 #   def o.each
20087 #     puts yield
20088 #     puts yield(1)
20089 #     puts yield(1, 2)
20090 #     3
20091 #   end
20092 # 
20093 #   # use o.each as an internal iterator directly.
20094 #   puts o.each {|*x| puts x; [:b, *x] }
20095 #   # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
20096 # 
20097 #   # convert o.each to an external iterator for
20098 #   # implementing an internal iterator.
20099 #   puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
20100 #   # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
20101 class Enumerator < Object
20102 include Enumerable
20103 class Lazy < Enumerator
20104 ##
20105 # Creates a new Lazy enumerator. When the enumerator is actually enumerated
20106 # (e.g. by calling #force), +obj+ will be enumerated and each value passed
20107 # to the given block. The block can yield values back using +yielder+.
20108 # For example, to create a method +filter_map+ in both lazy and
20109 # non-lazy fashions:
20110 # 
20111 #   module Enumerable
20112 #     def filter_map(&block)
20113 #       map(&block).compact
20114 #     end
20115 #   end
20116 # 
20117 #   class Enumerator::Lazy
20118 #     def filter_map
20119 #       Lazy.new(self) do |yielder, *values|
20120 #         result = yield *values
20121 #         yielder << result if result
20122 #       end
20123 #     end
20124 #   end
20125 # 
20126 #   (1..Float::INFINITY).lazy.filter_map{|i| i*i if i.even?}.first(5)
20127 #       # => [4, 16, 36, 64, 100]
20128 def self.new(obj, size=null, &block); end
20129 ##
20130 # Similar to Kernel#to_enum, except it returns a lazy enumerator.
20131 # This makes it easy to define Enumerable methods that will
20132 # naturally remain lazy if called from a lazy enumerator.
20133 # 
20134 # For example, continuing from the example in Kernel#to_enum:
20135 # 
20136 #   # See Kernel#to_enum for the definition of repeat
20137 #   r = 1..Float::INFINITY
20138 #   r.repeat(2).first(5) # => [1, 1, 2, 2, 3]
20139 #   r.repeat(2).class # => Enumerator
20140 #   r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop!
20141 #   # works naturally on lazy enumerator:
20142 #   r.lazy.repeat(2).class # => Enumerator::Lazy
20143 #   r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9]
20144 def to_enum(); Enumerator::Lazy.new; end
20145 ##
20146 # Similar to Kernel#to_enum, except it returns a lazy enumerator.
20147 # This makes it easy to define Enumerable methods that will
20148 # naturally remain lazy if called from a lazy enumerator.
20149 # 
20150 # For example, continuing from the example in Kernel#to_enum:
20151 # 
20152 #   # See Kernel#to_enum for the definition of repeat
20153 #   r = 1..Float::INFINITY
20154 #   r.repeat(2).first(5) # => [1, 1, 2, 2, 3]
20155 #   r.repeat(2).class # => Enumerator
20156 #   r.repeat(2).map{|n| n ** 2}.first(5) # => endless loop!
20157 #   # works naturally on lazy enumerator:
20158 #   r.lazy.repeat(2).class # => Enumerator::Lazy
20159 #   r.lazy.repeat(2).map{|n| n ** 2}.first(5) # => [1, 1, 4, 4, 9]
20160 def enum_for(); Enumerator::Lazy.new; end
20161 ##
20162 # Returns a new lazy enumerator with the concatenated results of running
20163 # <i>block</i> once for every element in <i>lazy</i>.
20164 # 
20165 #   ["foo", "bar"].lazy.flat_map {|i| i.each_char.lazy}.force
20166 #   #=> ["f", "o", "o", "b", "a", "r"]
20167 # 
20168 # A value <i>x</i> returned by <i>block</i> is decomposed if either of
20169 # the following conditions is true:
20170 # 
20171 #   a) <i>x</i> responds to both each and force, which means that
20172 #      <i>x</i> is a lazy enumerator.
20173 #   b) <i>x</i> is an array or responds to to_ary.
20174 # 
20175 # Otherwise, <i>x</i> is contained as-is in the return value.
20176 # 
20177 #   [{a:1}, {b:2}].lazy.flat_map {|i| i}.force
20178 #   #=> [{:a=>1}, {:b=>2}]
20179 def flat_map(&block); Enumerator::Lazy.new; end
20180 end
20181 
20182 class Generator < Object
20183 include Enumerable
20184 end
20185 
20186 class Yielder < Object
20187 end
20188 
20189 ##
20190 # Creates a new Enumerator object, which can be used as an
20191 # Enumerable.
20192 # 
20193 # In the first form, iteration is defined by the given block, in
20194 # which a "yielder" object, given as block parameter, can be used to
20195 # yield a value by calling the +yield+ method (aliased as +<<+):
20196 # 
20197 #   fib = Enumerator.new do |y|
20198 #     a = b = 1
20199 #     loop do
20200 #       y << a
20201 #       a, b = b, a + b
20202 #     end
20203 #   end
20204 # 
20205 #   p fib.take(10) # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
20206 # 
20207 # The optional parameter can be used to specify how to calculate the size
20208 # in a lazy fashion (see Enumerator#size). It can either be a value or
20209 # a callable object.
20210 # 
20211 # In the second, deprecated, form, a generated Enumerator iterates over the
20212 # given object using the given method with the given arguments passed.
20213 # 
20214 # Use of this form is discouraged.  Use Kernel#enum_for or Kernel#to_enum
20215 # instead.
20216 # 
20217 #   e = Enumerator.new(ObjectSpace, :each_object)
20218 #       #-> ObjectSpace.enum_for(:each_object)
20219 # 
20220 #   e.select { |obj| obj.is_a?(Class) }  #=> array of all classes
20221 def self.new(size = null, &block); end
20222 ##
20223 # Iterates over the block according to how this Enumerable was constructed.
20224 # If no block is given, returns self.
20225 def each(&block); end
20226 ##
20227 # Same as Enumerator#with_index(0), i.e. there is no starting offset.
20228 # 
20229 # If no block is given, a new Enumerator is returned that includes the index.
20230 def each_with_index(&block); end
20231 ##
20232 # Iterates the given block for each element with an arbitrary object, +obj+,
20233 # and returns +obj+
20234 # 
20235 # If no block is given, returns a new Enumerator.
20236 # 
20237 # === Example
20238 # 
20239 #   to_three = Enumerator.new do |y|
20240 #     3.times do |x|
20241 #       y << x
20242 #     end
20243 #   end
20244 # 
20245 #   to_three_with_string = to_three.with_object("foo")
20246 #   to_three_with_string.each do |x,string|
20247 #     puts "#{string}: #{x}"
20248 #   end
20249 # 
20250 #   # => foo:0
20251 #   # => foo:1
20252 #   # => foo:2
20253 def with_object(obj, &block); end
20254 ##
20255 # Iterates the given block for each element with an index, which
20256 # starts from +offset+.  If no block is given, returns a new Enumerator
20257 # that includes the index, starting from +offset+
20258 # 
20259 # +offset+:: the starting index to use
20260 def with_index(offset = 0, &block); end
20261 ##
20262 # Returns the next object as an array in the enumerator, and move the
20263 # internal position forward.  When the position reached at the end,
20264 # StopIteration is raised.
20265 # 
20266 # This method can be used to distinguish <code>yield</code> and <code>yield
20267 # nil</code>.
20268 # 
20269 # === Example
20270 # 
20271 #   o = Object.new
20272 #   def o.each
20273 #     yield
20274 #     yield 1
20275 #     yield 1, 2
20276 #     yield nil
20277 #     yield [1, 2]
20278 #   end
20279 #   e = o.to_enum
20280 #   p e.next_values
20281 #   p e.next_values
20282 #   p e.next_values
20283 #   p e.next_values
20284 #   p e.next_values
20285 #   e = o.to_enum
20286 #   p e.next
20287 #   p e.next
20288 #   p e.next
20289 #   p e.next
20290 #   p e.next
20291 # 
20292 #   ## yield args       next_values      next
20293 #   #  yield            []               nil
20294 #   #  yield 1          [1]              1
20295 #   #  yield 1, 2       [1, 2]           [1, 2]
20296 #   #  yield nil        [nil]            nil
20297 #   #  yield [1, 2]     [[1, 2]]         [1, 2]
20298 # 
20299 # Note that +next_values+ does not affect other non-external enumeration
20300 # methods unless underlying iteration method itself has side-effect, e.g.
20301 # IO#each_line.
20302 def next_values; []; end
20303 ##
20304 # Returns the next object as an array, similar to Enumerator#next_values, but
20305 # doesn't move the internal position forward.  If the position is already at
20306 # the end, StopIteration is raised.
20307 # 
20308 # === Example
20309 # 
20310 #   o = Object.new
20311 #   def o.each
20312 #     yield
20313 #     yield 1
20314 #     yield 1, 2
20315 #   end
20316 #   e = o.to_enum
20317 #   p e.peek_values    #=> []
20318 #   e.next
20319 #   p e.peek_values    #=> [1]
20320 #   p e.peek_values    #=> [1]
20321 #   e.next
20322 #   p e.peek_values    #=> [1, 2]
20323 #   e.next
20324 #   p e.peek_values    # raises StopIteration
20325 def peek_values; []; end
20326 ##
20327 # Returns the next object in the enumerator, and move the internal position
20328 # forward.  When the position reached at the end, StopIteration is raised.
20329 # 
20330 # === Example
20331 # 
20332 #   a = [1,2,3]
20333 #   e = a.to_enum
20334 #   p e.next   #=> 1
20335 #   p e.next   #=> 2
20336 #   p e.next   #=> 3
20337 #   p e.next   #raises StopIteration
20338 # 
20339 # Note that enumeration sequence by +next+ does not affect other non-external
20340 # enumeration methods, unless the underlying iteration methods itself has
20341 # side-effect, e.g. IO#each_line.
20342 def next; Object.new; end
20343 ##
20344 # Returns the next object in the enumerator, but doesn't move the internal
20345 # position forward.  If the position is already at the end, StopIteration
20346 # is raised.
20347 # 
20348 # === Example
20349 # 
20350 #   a = [1,2,3]
20351 #   e = a.to_enum
20352 #   p e.next   #=> 1
20353 #   p e.peek   #=> 2
20354 #   p e.peek   #=> 2
20355 #   p e.peek   #=> 2
20356 #   p e.next   #=> 2
20357 #   p e.next   #=> 3
20358 #   p e.next   #raises StopIteration
20359 def peek; Object.new; end
20360 ##
20361 # Sets the value to be returned by the next yield inside +e+.
20362 # 
20363 # If the value is not set, the yield returns nil.
20364 # 
20365 # This value is cleared after being yielded.
20366 # 
20367 #   o = Object.new
20368 #   def o.each
20369 #     x = yield         # (2) blocks
20370 #     p x               # (5) => "foo"
20371 #     x = yield         # (6) blocks
20372 #     p x               # (8) => nil
20373 #     x = yield         # (9) blocks
20374 #     p x               # not reached w/o another e.next
20375 #   end
20376 # 
20377 #   e = o.to_enum
20378 #   e.next              # (1)
20379 #   e.feed "foo"        # (3)
20380 #   e.next              # (4)
20381 #   e.next              # (7)
20382 #                       # (10)
20383 def feed obj; end
20384 ##
20385 # Rewinds the enumeration sequence to the beginning.
20386 # 
20387 # If the enclosed object responds to a "rewind" method, it is called.
20388 def rewind; Exception.new; end
20389 ##
20390 # Creates a printable version of <i>e</i>.
20391 def inspect; ''; end
20392 ##
20393 # Returns the size of the enumerator, or +nil+ if it can't be calculated lazily.
20394 # 
20395 #   (1..100).to_a.permutation(4).size # => 94109400
20396 #   loop.size # => Float::INFINITY
20397 #   (1..100).drop_while.size # => nil
20398 def size; 1 || 0.0 || nil; end
20399 end
20400 
20401 ##
20402 # Raised to stop the iteration, in particular by Enumerator#next. It is
20403 # rescued by Kernel#loop.
20404 # 
20405 #   loop do
20406 #     puts "Hello"
20407 #     raise StopIteration
20408 #     puts "World"
20409 #   end
20410 #   puts "Done!"
20411 # 
20412 # <em>produces:</em>
20413 # 
20414 #   Hello
20415 #   Done!
20416 class StopIteration < IndexError
20417 ##
20418 # Returns the return value of the iterator.
20419 # 
20420 #   o = Object.new
20421 #   def o.each
20422 #     yield 1
20423 #     yield 2
20424 #     yield 3
20425 #     100
20426 #   end
20427 # 
20428 #   e = o.to_enum
20429 # 
20430 #   puts e.next                   #=> 1
20431 #   puts e.next                   #=> 2
20432 #   puts e.next                   #=> 3
20433 # 
20434 #   begin
20435 #     e.next
20436 #   rescue StopIteration => ex
20437 #     puts ex.result              #=> 100
20438 #   end
20439 def result; Object.new; end
20440 end
20441 
20442 ##
20443 # Fibers are primitives for implementing light weight cooperative
20444 # concurrency in Ruby. Basically they are a means of creating code blocks
20445 # that can be paused and resumed, much like threads. The main difference
20446 # is that they are never preempted and that the scheduling must be done by
20447 # the programmer and not the VM.
20448 # 
20449 # As opposed to other stackless light weight concurrency models, each fiber
20450 # comes with a small 4KB stack. This enables the fiber to be paused from deeply
20451 # nested function calls within the fiber block.
20452 # 
20453 # When a fiber is created it will not run automatically. Rather it must be
20454 # be explicitly asked to run using the <code>Fiber#resume</code> method.
20455 # The code running inside the fiber can give up control by calling
20456 # <code>Fiber.yield</code> in which case it yields control back to caller
20457 # (the caller of the <code>Fiber#resume</code>).
20458 # 
20459 # Upon yielding or termination the Fiber returns the value of the last
20460 # executed expression
20461 # 
20462 # For instance:
20463 # 
20464 #   fiber = Fiber.new do
20465 #     Fiber.yield 1
20466 #     2
20467 #   end
20468 # 
20469 #   puts fiber.resume
20470 #   puts fiber.resume
20471 #   puts fiber.resume
20472 # 
20473 # <em>produces</em>
20474 # 
20475 #   1
20476 #   2
20477 #   FiberError: dead fiber called
20478 # 
20479 # The <code>Fiber#resume</code> method accepts an arbitrary number of
20480 # parameters, if it is the first call to <code>resume</code> then they
20481 # will be passed as block arguments. Otherwise they will be the return
20482 # value of the call to <code>Fiber.yield</code>
20483 # 
20484 # Example:
20485 # 
20486 #   fiber = Fiber.new do |first|
20487 #     second = Fiber.yield first + 2
20488 #   end
20489 # 
20490 #   puts fiber.resume 10
20491 #   puts fiber.resume 14
20492 #   puts fiber.resume 18
20493 # 
20494 # <em>produces</em>
20495 # 
20496 #   12
20497 #   14
20498 #   FiberError: dead fiber called
20499 class Fiber < Object
20500 ##
20501 # Yields control back to the context that resumed the fiber, passing
20502 # along any arguments that were passed to it. The fiber will resume
20503 # processing at this point when <code>resume</code> is called next.
20504 # Any arguments passed to the next <code>resume</code> will be the
20505 # value that this <code>Fiber.yield</code> expression evaluates to.
20506 def self.yield(); Object.new; end
20507 ##
20508 # Resumes the fiber from the point at which the last <code>Fiber.yield</code>
20509 # was called, or starts running it if it is the first call to
20510 # <code>resume</code>. Arguments passed to resume will be the value of
20511 # the <code>Fiber.yield</code> expression or will be passed as block
20512 # parameters to the fiber's block if this is the first <code>resume</code>.
20513 # 
20514 # Alternatively, when resume is called it evaluates to the arguments passed
20515 # to the next <code>Fiber.yield</code> statement inside the fiber's block
20516 # or to the block value if it runs to completion without any
20517 # <code>Fiber.yield</code>
20518 def resume(); Object.new; end
20519 ##
20520 # Transfer control to another fiber, resuming it from where it last
20521 # stopped or starting it if it was not resumed before. The calling
20522 # fiber will be suspended much like in a call to
20523 # <code>Fiber.yield</code>. You need to <code>require 'fiber'</code>
20524 # before using this method.
20525 # 
20526 # The fiber which receives the transfer call is treats it much like
20527 # a resume call. Arguments passed to transfer are treated like those
20528 # passed to resume.
20529 # 
20530 # You cannot resume a fiber that transferred control to another one.
20531 # This will cause a double resume error. You need to transfer control
20532 # back to this fiber before it can yield and resume.
20533 # 
20534 # Example:
20535 # 
20536 #   fiber1 = Fiber.new do
20537 #     puts "In Fiber 1"
20538 #     Fiber.yield
20539 #   end
20540 # 
20541 #   fiber2 = Fiber.new do
20542 #     puts "In Fiber 2"
20543 #     fiber1.transfer
20544 #     puts "Never see this message"
20545 #   end
20546 # 
20547 #   fiber3 = Fiber.new do
20548 #     puts "In Fiber 3"
20549 #   end
20550 # 
20551 #   fiber2.resume
20552 #   fiber3.resume
20553 # 
20554 #   <em>produces</em>
20555 # 
20556 #   In fiber 2
20557 #   In fiber 1
20558 #   In fiber 3
20559 def transfer(); Object.new; end
20560 ##
20561 # Returns true if the fiber can still be resumed (or transferred
20562 # to). After finishing execution of the fiber block this method will
20563 # always return false. You need to <code>require 'fiber'</code>
20564 # before using this method.
20565 def alive?; true || false; end
20566 ##
20567 # Returns the current fiber. You need to <code>require 'fiber'</code>
20568 # before using this method. If you are not running in the context of
20569 # a fiber this method will return the root fiber.
20570 def self.current(); Fiber.new; end
20571 end
20572 
20573 ##
20574 # Raised when an invalid operation is attempted on a Fiber, in
20575 # particular when attempting to call/resume a dead fiber,
20576 # attempting to yield from the root fiber, or calling a fiber across
20577 # threads.
20578 # 
20579 #    fiber = Fiber.new{}
20580 #    fiber.resume #=> nil
20581 #    fiber.resume #=> FiberError: dead fiber called
20582 class FiberError < StandardError
20583 end
20584 
20585 ##
20586 # Continuation objects are generated by Kernel#callcc,
20587 # after having +require+d <i>continuation</i>. They hold
20588 # a return address and execution context, allowing a nonlocal return
20589 # to the end of the <code>callcc</code> block from anywhere within a
20590 # program. Continuations are somewhat analogous to a structured
20591 # version of C's <code>setjmp/longjmp</code> (although they contain
20592 # more state, so you might consider them closer to threads).
20593 # 
20594 # For instance:
20595 # 
20596 #    require "continuation"
20597 #    arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
20598 #    callcc{|cc| $cc = cc}
20599 #    puts(message = arr.shift)
20600 #    $cc.call unless message =~ /Max/
20601 # 
20602 # <em>produces:</em>
20603 # 
20604 #    Freddie
20605 #    Herbie
20606 #    Ron
20607 #    Max
20608 # 
20609 # This (somewhat contrived) example allows the inner loop to abandon
20610 # processing early:
20611 # 
20612 #    require "continuation"
20613 #    callcc {|cont|
20614 #      for i in 0..4
20615 #        print "\n#{i}: "
20616 #        for j in i*5...(i+1)*5
20617 #          cont.call() if j == 17
20618 #          printf "%3d", j
20619 #        end
20620 #      end
20621 #    }
20622 #    puts
20623 # 
20624 # <em>produces:</em>
20625 # 
20626 #    0:   0  1  2  3  4
20627 #    1:   5  6  7  8  9
20628 #    2:  10 11 12 13 14
20629 #    3:  15 16
20630 class Continuation < Object
20631 ##
20632 # Invokes the continuation. The program continues from the end of the
20633 # <code>callcc</code> block. If no arguments are given, the original
20634 # <code>callcc</code> returns <code>nil</code>. If one argument is
20635 # given, <code>callcc</code> returns it. Otherwise, an array
20636 # containing <i>args</i> is returned.
20637 # 
20638 #    callcc {|cont|  cont.call }           #=> nil
20639 #    callcc {|cont|  cont.call 1 }         #=> 1
20640 #    callcc {|cont|  cont.call 1, 2, 3 }   #=> [1, 2, 3]
20641 def call(); end
20642 ##
20643 # Invokes the continuation. The program continues from the end of the
20644 # <code>callcc</code> block. If no arguments are given, the original
20645 # <code>callcc</code> returns <code>nil</code>. If one argument is
20646 # given, <code>callcc</code> returns it. Otherwise, an array
20647 # containing <i>args</i> is returned.
20648 # 
20649 #    callcc {|cont|  cont.call }           #=> nil
20650 #    callcc {|cont|  cont.call 1 }         #=> 1
20651 #    callcc {|cont|  cont.call 1, 2, 3 }   #=> [1, 2, 3]
20652 def []; end
20653 end
20654 
20655 ##
20656 # A complex number can be represented as a paired real number with
20657 # imaginary unit; a+bi.  Where a is real part, b is imaginary part
20658 # and i is imaginary unit.  Real a equals complex a+0i
20659 # mathematically.
20660 # 
20661 # In ruby, you can create complex object with Complex, Complex::rect,
20662 # Complex::polar or to_c method.
20663 # 
20664 #    Complex(1)           #=> (1+0i)
20665 #    Complex(2, 3)        #=> (2+3i)
20666 #    Complex.polar(2, 3)  #=> (-1.9799849932008908+0.2822400161197344i)
20667 #    3.to_c               #=> (3+0i)
20668 # 
20669 # You can also create complex object from floating-point numbers or
20670 # strings.
20671 # 
20672 #    Complex(0.3)         #=> (0.3+0i)
20673 #    Complex('0.3-0.5i')  #=> (0.3-0.5i)
20674 #    Complex('2/3+3/4i')  #=> ((2/3)+(3/4)*i)
20675 #    Complex('1@2')       #=> (-0.4161468365471424+0.9092974268256817i)
20676 # 
20677 #    0.3.to_c             #=> (0.3+0i)
20678 #    '0.3-0.5i'.to_c      #=> (0.3-0.5i)
20679 #    '2/3+3/4i'.to_c      #=> ((2/3)+(3/4)*i)
20680 #    '1@2'.to_c           #=> (-0.4161468365471424+0.9092974268256817i)
20681 # 
20682 # A complex object is either an exact or an inexact number.
20683 # 
20684 #    Complex(1, 1) / 2    #=> ((1/2)+(1/2)*i)
20685 #    Complex(1, 1) / 2.0  #=> (0.5+0.5i)
20686 class Complex < Numeric
20687 class Compatible < Object
20688 end
20689 
20690 ##
20691 # Returns a complex object which denotes the given rectangular form.
20692 # 
20693 #    Complex.rectangular(1, 2)  #=> (1+2i)
20694 def self.rect(real, imag=0); []; end
20695 ##
20696 # Returns a complex object which denotes the given rectangular form.
20697 # 
20698 #    Complex.rectangular(1, 2)  #=> (1+2i)
20699 def self.rectangular(real, imag=0); []; end
20700 ##
20701 # Returns a complex object which denotes the given polar form.
20702 # 
20703 #    Complex.polar(3, 0)            #=> (3.0+0.0i)
20704 #    Complex.polar(3, Math::PI/2)   #=> (1.836909530733566e-16+3.0i)
20705 #    Complex.polar(3, Math::PI)     #=> (-3.0+3.673819061467132e-16i)
20706 #    Complex.polar(3, -Math::PI/2)  #=> (1.836909530733566e-16-3.0i)
20707 def self.polar(abs, arg=0); []; end
20708 ##
20709 # Returns the real part.
20710 # 
20711 #    Complex(7).real      #=> 7
20712 #    Complex(9, -4).real  #=> 9
20713 def real; 0; end
20714 ##
20715 # Returns the imaginary part.
20716 # 
20717 #    Complex(7).imaginary      #=> 0
20718 #    Complex(9, -4).imaginary  #=> -4
20719 def imag; 0; end
20720 ##
20721 # Returns the imaginary part.
20722 # 
20723 #    Complex(7).imaginary      #=> 0
20724 #    Complex(9, -4).imaginary  #=> -4
20725 def imaginary; 0; end
20726 ##
20727 # Returns negation of the value.
20728 # 
20729 #    -Complex(1, 2)  #=> (-1-2i)
20730 def -@; Complex.new; end
20731 ##
20732 # Performs addition.
20733 # 
20734 #    Complex(2, 3)  + Complex(2, 3)   #=> (4+6i)
20735 #    Complex(900)   + Complex(1)      #=> (901+0i)
20736 #    Complex(-2, 9) + Complex(-9, 2)  #=> (-11+11i)
20737 #    Complex(9, 8)  + 4               #=> (13+8i)
20738 #    Complex(20, 9) + 9.8             #=> (29.8+9i)
20739 def +; Complex.new; end
20740 ##
20741 # Performs subtraction.
20742 # 
20743 #    Complex(2, 3)  - Complex(2, 3)   #=> (0+0i)
20744 #    Complex(900)   - Complex(1)      #=> (899+0i)
20745 #    Complex(-2, 9) - Complex(-9, 2)  #=> (7+7i)
20746 #    Complex(9, 8)  - 4               #=> (5+8i)
20747 #    Complex(20, 9) - 9.8             #=> (10.2+9i)
20748 def -; Complex.new; end
20749 ##
20750 # Performs multiplication.
20751 # 
20752 #    Complex(2, 3)  * Complex(2, 3)   #=> (-5+12i)
20753 #    Complex(900)   * Complex(1)      #=> (900+0i)
20754 #    Complex(-2, 9) * Complex(-9, 2)  #=> (0-85i)
20755 #    Complex(9, 8)  * 4               #=> (36+32i)
20756 #    Complex(20, 9) * 9.8             #=> (196.0+88.2i)
20757 def *; Complex.new; end
20758 ##
20759 # Performs division.
20760 # 
20761 #    Complex(2, 3)  / Complex(2, 3)   #=> ((1/1)+(0/1)*i)
20762 #    Complex(900)   / Complex(1)      #=> ((900/1)+(0/1)*i)
20763 #    Complex(-2, 9) / Complex(-9, 2)  #=> ((36/85)-(77/85)*i)
20764 #    Complex(9, 8)  / 4               #=> ((9/4)+(2/1)*i)
20765 #    Complex(20, 9) / 9.8             #=> (2.0408163265306123+0.9183673469387754i)
20766 def /; Complex.new; end
20767 ##
20768 # Performs division.
20769 # 
20770 #    Complex(2, 3)  / Complex(2, 3)   #=> ((1/1)+(0/1)*i)
20771 #    Complex(900)   / Complex(1)      #=> ((900/1)+(0/1)*i)
20772 #    Complex(-2, 9) / Complex(-9, 2)  #=> ((36/85)-(77/85)*i)
20773 #    Complex(9, 8)  / 4               #=> ((9/4)+(2/1)*i)
20774 #    Complex(20, 9) / 9.8             #=> (2.0408163265306123+0.9183673469387754i)
20775 def quo(numeric); Complex.new; end
20776 ##
20777 # Performs division as each part is a float, never returns a float.
20778 # 
20779 #    Complex(11, 22).fdiv(3)  #=> (3.6666666666666665+7.333333333333333i)
20780 def fdiv(numeric); Complex.new; end
20781 ##
20782 # Performs exponentiation.
20783 # 
20784 #    Complex('i') ** 2              #=> (-1+0i)
20785 #    Complex(-8) ** Rational(1, 3)  #=> (1.0000000000000002+1.7320508075688772i)
20786 def **; Complex.new; end
20787 ##
20788 # Returns true if cmp equals object numerically.
20789 # 
20790 #    Complex(2, 3)  == Complex(2, 3)   #=> true
20791 #    Complex(5)     == 5               #=> true
20792 #    Complex(0)     == 0.0             #=> true
20793 #    Complex('1/3') == 0.33            #=> false
20794 #    Complex('1/2') == '1/2'           #=> false
20795 def ==; true || false; end
20796 ##
20797 # Returns the absolute part of its polar form.
20798 # 
20799 #    Complex(-1).abs         #=> 1
20800 #    Complex(3.0, -4.0).abs  #=> 5.0
20801 def abs; 0; end
20802 ##
20803 # Returns the absolute part of its polar form.
20804 # 
20805 #    Complex(-1).abs         #=> 1
20806 #    Complex(3.0, -4.0).abs  #=> 5.0
20807 def magnitude; 0; end
20808 ##
20809 # Returns square of the absolute value.
20810 # 
20811 #    Complex(-1).abs2         #=> 1
20812 #    Complex(3.0, -4.0).abs2  #=> 25.0
20813 def abs2; 0; end
20814 ##
20815 # Returns the angle part of its polar form.
20816 # 
20817 #    Complex.polar(3, Math::PI/2).arg  #=> 1.5707963267948966
20818 def arg; 0.0; end
20819 ##
20820 # Returns the angle part of its polar form.
20821 # 
20822 #    Complex.polar(3, Math::PI/2).arg  #=> 1.5707963267948966
20823 def angle; 0.0; end
20824 ##
20825 # Returns the angle part of its polar form.
20826 # 
20827 #    Complex.polar(3, Math::PI/2).arg  #=> 1.5707963267948966
20828 def phase; 0.0; end
20829 ##
20830 # Returns the complex conjugate.
20831 # 
20832 #    Complex(1, 2).conjugate  #=> (1-2i)
20833 def conj; Complex.new; end
20834 ##
20835 # Returns the complex conjugate.
20836 # 
20837 #    Complex(1, 2).conjugate  #=> (1-2i)
20838 def conjugate; Complex.new; end
20839 ##
20840 # Returns false.
20841 def real?; false; end
20842 ##
20843 # Returns the numerator.
20844 # 
20845 #        1   2       3+4i  <-  numerator
20846 #        - + -i  ->  ----
20847 #        2   3        6    <-  denominator
20848 # 
20849 #    c = Complex('1/2+2/3i')  #=> ((1/2)+(2/3)*i)
20850 #    n = c.numerator          #=> (3+4i)
20851 #    d = c.denominator        #=> 6
20852 #    n / d                    #=> ((1/2)+(2/3)*i)
20853 #    Complex(Rational(n.real, d), Rational(n.imag, d))
20854 #                             #=> ((1/2)+(2/3)*i)
20855 # See denominator.
20856 def numerator; 0; end
20857 ##
20858 # Returns the denominator (lcm of both denominator - real and imag).
20859 # 
20860 # See numerator.
20861 def denominator; 0; end
20862 ##
20863 # Returns the value as a string.
20864 # 
20865 #    Complex(2).to_s                       #=> "2+0i"
20866 #    Complex('-8/6').to_s                  #=> "-4/3+0i"
20867 #    Complex('1/2i').to_s                  #=> "0+1/2i"
20868 #    Complex(0, Float::INFINITY).to_s      #=> "0+Infinity*i"
20869 #    Complex(Float::NAN, Float::NAN).to_s  #=> "NaN+NaN*i"
20870 def to_s; ''; end
20871 ##
20872 # Returns the value as a string for inspection.
20873 # 
20874 #    Complex(2).inspect                       #=> "(2+0i)"
20875 #    Complex('-8/6').inspect                  #=> "((-4/3)+0i)"
20876 #    Complex('1/2i').inspect                  #=> "(0+(1/2)*i)"
20877 #    Complex(0, Float::INFINITY).inspect      #=> "(0+Infinity*i)"
20878 #    Complex(Float::NAN, Float::NAN).inspect  #=> "(NaN+NaN*i)"
20879 def inspect; ''; end
20880 ##
20881 # Returns the value as an integer if possible (the imaginary part
20882 # should be exactly zero).
20883 # 
20884 #    Complex(1, 0).to_i    #=> 1
20885 #    Complex(1, 0.0).to_i  # RangeError
20886 #    Complex(1, 2).to_i    # RangeError
20887 def to_i; 0; end
20888 ##
20889 # Returns the value as a float if possible (the imaginary part should
20890 # be exactly zero).
20891 # 
20892 #    Complex(1, 0).to_f    #=> 1.0
20893 #    Complex(1, 0.0).to_f  # RangeError
20894 #    Complex(1, 2).to_f    # RangeError
20895 def to_f; 0.0; end
20896 ##
20897 # Returns the value as a rational if possible (the imaginary part
20898 # should be exactly zero).
20899 # 
20900 #    Complex(1, 0).to_r    #=> (1/1)
20901 #    Complex(1, 0.0).to_r  # RangeError
20902 #    Complex(1, 2).to_r    # RangeError
20903 # 
20904 # See rationalize.
20905 def to_r; Rational.new; end
20906 ##
20907 # Returns the value as a rational if possible (the imaginary part
20908 # should be exactly zero).
20909 # 
20910 #    Complex(1.0/3, 0).rationalize  #=> (1/3)
20911 #    Complex(1, 0.0).rationalize    # RangeError
20912 #    Complex(1, 2).rationalize      # RangeError
20913 # 
20914 # See to_r.
20915 def rationalize(eps=0); Rational.new; end
20916 ##
20917 # Returns self.
20918 # 
20919 #    Complex(2).to_c      #=> (2+0i)
20920 #    Complex(-8, 6).to_c  #=> (-8+6i)
20921 def to_c; self; end
20922 end
20923 
20924 ##
20925 # Raised when an IO operation fails.
20926 # 
20927 #    File.open("/etc/hosts") {|f| f << "example"}
20928 #      #=> IOError: not opened for writing
20929 # 
20930 #    File.open("/etc/hosts") {|f| f.close; f.read }
20931 #      #=> IOError: closed stream
20932 # 
20933 # Note that some IO failures raise +SystemCallError+s and these are not
20934 # subclasses of IOError:
20935 # 
20936 #    File.open("does/not/exist")
20937 #      #=> Errno::ENOENT: No such file or directory - does/not/exist
20938 class IOError < StandardError
20939 end
20940 
20941 ##
20942 # Raised by some IO operations when reaching the end of file. Many IO
20943 # methods exist in two forms,
20944 # 
20945 # one that returns +nil+ when the end of file is reached, the other
20946 # raises EOFError +EOFError+.
20947 # 
20948 # +EOFError+ is a subclass of +IOError+.
20949 # 
20950 #    file = File.open("/etc/hosts")
20951 #    file.read
20952 #    file.gets     #=> nil
20953 #    file.readline #=> EOFError: end of file reached
20954 class EOFError < IOError
20955 end
20956 
20957 ##
20958 # +ARGF+ is a stream designed for use in scripts that process files given as
20959 # command-line arguments or passed in via STDIN.
20960 # 
20961 # The arguments passed to your script are stored in the +ARGV+ Array, one
20962 # argument per element. +ARGF+ assumes that any arguments that aren't
20963 # filenames have been removed from +ARGV+. For example:
20964 # 
20965 #     $ ruby argf.rb --verbose file1 file2
20966 # 
20967 #     ARGV  #=> ["--verbose", "file1", "file2"]
20968 #     option = ARGV.shift #=> "--verbose"
20969 #     ARGV  #=> ["file1", "file2"]
20970 # 
20971 # You can now use +ARGF+ to work with a concatenation of each of these named
20972 # files. For instance, +ARGF.read+ will return the contents of _file1_
20973 # followed by the contents of _file2_.
20974 # 
20975 # After a file in +ARGV+ has been read +ARGF+ removes it from the Array.
20976 # Thus, after all files have been read +ARGV+ will be empty.
20977 # 
20978 # You can manipulate +ARGV+ yourself to control what +ARGF+ operates on. If
20979 # you remove a file from +ARGV+, it is ignored by +ARGF+; if you add files to
20980 # +ARGV+, they are treated as if they were named on the command line. For
20981 # example:
20982 # 
20983 #     ARGV.replace ["file1"]
20984 #     ARGF.readlines # Returns the contents of file1 as an Array
20985 #     ARGV           #=> []
20986 #     ARGV.replace ["file2", "file3"]
20987 #     ARGF.read      # Returns the contents of file2 and file3
20988 # 
20989 # If +ARGV+ is empty, +ARGF+ acts as if it contained STDIN, i.e. the data
20990 # piped to your script. For example:
20991 # 
20992 #     $ echo "glark" | ruby -e 'p ARGF.read'
20993 #     "glark\n"
20994 class ARGF < Object
20995 include Enumerable
20996 ##
20997 # Returns "ARGF".
20998 def to_s; ''; end
20999 ##
21000 # Returns the +ARGV+ array, which contains the arguments passed to your
21001 # script, one per element.
21002 # 
21003 # For example:
21004 # 
21005 #     $ ruby argf.rb -v glark.txt
21006 # 
21007 #     ARGF.argv   #=> ["-v", "glark.txt"]
21008 def argv; ARGV; end
21009 ##
21010 # Returns an integer representing the numeric file descriptor for
21011 # the current file. Raises an +ArgumentError+ if there isn't a current file.
21012 # 
21013 #    ARGF.fileno    #=> 3
21014 def fileno; 0; end
21015 ##
21016 # Returns an integer representing the numeric file descriptor for
21017 # the current file. Raises an +ArgumentError+ if there isn't a current file.
21018 # 
21019 #    ARGF.fileno    #=> 3
21020 def to_i; 0; end
21021 ##
21022 # Returns an +IO+ object representing the current file. This will be a
21023 # +File+ object unless the current file is a stream such as STDIN.
21024 # 
21025 # For example:
21026 # 
21027 #    ARGF.to_io    #=> #<File:glark.txt>
21028 #    ARGF.to_io    #=> #<IO:<STDIN>>
21029 def to_io; IO; end
21030 ##
21031 # Returns IO instance tied to _ARGF_ for writing if inplace mode is
21032 # enabled.
21033 def to_write_io; IO.new; end
21034 ##
21035 # Returns an enumerator which iterates over each line (separated by _sep_,
21036 # which defaults to your platform's newline character) of each file in
21037 # +ARGV+. If a block is supplied, each line in turn will be yielded to the
21038 # block, otherwise an enumerator is returned.
21039 # The optional _limit_ argument is a +Fixnum+ specifying the maximum
21040 # length of each line; longer lines will be split according to this limit.
21041 # 
21042 # This method allows you to treat the files supplied on the command line as
21043 # a single file consisting of the concatenation of each named file. After
21044 # the last line of the first file has been returned, the first line of the
21045 # second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can
21046 # be used to determine the filename and line number, respectively, of the
21047 # current line.
21048 # 
21049 # For example, the following code prints out each line of each named file
21050 # prefixed with its line number, displaying the filename once per file:
21051 # 
21052 #    ARGF.lines do |line|
21053 #      puts ARGF.filename if ARGF.lineno == 1
21054 #      puts "#{ARGF.lineno}: #{line}"
21055 #    end
21056 def each(sep=$/, &block); Enumerator.new; end
21057 ##
21058 # Returns an enumerator which iterates over each line (separated by _sep_,
21059 # which defaults to your platform's newline character) of each file in
21060 # +ARGV+. If a block is supplied, each line in turn will be yielded to the
21061 # block, otherwise an enumerator is returned.
21062 # The optional _limit_ argument is a +Fixnum+ specifying the maximum
21063 # length of each line; longer lines will be split according to this limit.
21064 # 
21065 # This method allows you to treat the files supplied on the command line as
21066 # a single file consisting of the concatenation of each named file. After
21067 # the last line of the first file has been returned, the first line of the
21068 # second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can
21069 # be used to determine the filename and line number, respectively, of the
21070 # current line.
21071 # 
21072 # For example, the following code prints out each line of each named file
21073 # prefixed with its line number, displaying the filename once per file:
21074 # 
21075 #    ARGF.lines do |line|
21076 #      puts ARGF.filename if ARGF.lineno == 1
21077 #      puts "#{ARGF.lineno}: #{line}"
21078 #    end
21079 def each_line(sep=$/, &block); Enumerator.new; end
21080 ##
21081 #  Iterates over each byte of each file in +ARGV+.
21082 #  A byte is returned as a +Fixnum+ in the range 0..255.
21083 # 
21084 #  This method allows you to treat the files supplied on the command line as
21085 #  a single file consisting of the concatenation of each named file. After
21086 #  the last byte of the first file has been returned, the first byte of the
21087 #  second file is returned. The +ARGF.filename+ method can be used to
21088 #  determine the filename of the current byte.
21089 # 
21090 #  If no block is given, an enumerator is returned instead.
21091 # 
21092 # For example:
21093 # 
21094 #     ARGF.bytes.to_a  #=> [35, 32, ... 95, 10]
21095 def bytes(&block); Enumerator.new; end
21096 ##
21097 #  Iterates over each byte of each file in +ARGV+.
21098 #  A byte is returned as a +Fixnum+ in the range 0..255.
21099 # 
21100 #  This method allows you to treat the files supplied on the command line as
21101 #  a single file consisting of the concatenation of each named file. After
21102 #  the last byte of the first file has been returned, the first byte of the
21103 #  second file is returned. The +ARGF.filename+ method can be used to
21104 #  determine the filename of the current byte.
21105 # 
21106 #  If no block is given, an enumerator is returned instead.
21107 # 
21108 # For example:
21109 # 
21110 #     ARGF.bytes.to_a  #=> [35, 32, ... 95, 10]
21111 def each_byte(&block); Enumerator.new; end
21112 ##
21113 # Iterates over each character of each file in +ARGF+.
21114 # 
21115 # This method allows you to treat the files supplied on the command line as
21116 # a single file consisting of the concatenation of each named file. After
21117 # the last character of the first file has been returned, the first
21118 # character of the second file is returned. The +ARGF.filename+ method can
21119 # be used to determine the name of the file in which the current character
21120 # appears.
21121 # 
21122 # If no block is given, an enumerator is returned instead.
21123 def each_char(&block); Enumerator.new; end
21124 ##
21125 # Iterates over each codepoint of each file in +ARGF+.
21126 # 
21127 # This method allows you to treat the files supplied on the command line as
21128 # a single file consisting of the concatenation of each named file. After
21129 # the last codepoint of the first file has been returned, the first
21130 # codepoint of the second file is returned. The +ARGF.filename+ method can
21131 # be used to determine the name of the file in which the current codepoint
21132 # appears.
21133 # 
21134 # If no block is given, an enumerator is returned instead.
21135 def each_codepoint(&block); Enumerator.new; end
21136 ##
21137 #  Reads _length_ bytes from ARGF. The files named on the command line
21138 #  are concatenated and treated as a single file by this method, so when
21139 #  called without arguments the contents of this pseudo file are returned in
21140 #  their entirety.
21141 # 
21142 #  _length_ must be a non-negative integer or nil. If it is a positive
21143 #  integer, +read+ tries to read at most _length_ bytes. It returns nil
21144 #  if an EOF was encountered before anything could be read. Fewer than
21145 #  _length_ bytes may be returned if an EOF is encountered during the read.
21146 # 
21147 #  If _length_ is omitted or is _nil_, it reads until EOF. A String is
21148 #  returned even if EOF is encountered before any data is read.
21149 # 
21150 #  If _length_ is zero, it returns _""_.
21151 # 
21152 #  If the optional _outbuf_ argument is present, it must reference a String,
21153 #  which will receive the data.
21154 #  The <i>outbuf</i> will contain only the received data after the method call
21155 #  even if it is not empty at the beginning.
21156 # 
21157 # For example:
21158 # 
21159 #     $ echo "small" > small.txt
21160 #     $ echo "large" > large.txt
21161 #     $ ./glark.rb small.txt large.txt
21162 # 
21163 #     ARGF.read      #=> "small\nlarge"
21164 #     ARGF.read(200) #=> "small\nlarge"
21165 #     ARGF.read(2)   #=> "sm"
21166 #     ARGF.read(0)   #=> ""
21167 # 
21168 #  Note that this method behaves like fread() function in C.  If you need the
21169 #  behavior like read(2) system call, consider +ARGF.readpartial+.
21170 def read(length=0, outbuf=0); '' || nil; end
21171 ##
21172 # Reads at most _maxlen_ bytes from the ARGF stream. It blocks only if
21173 # +ARGF+ has no data immediately available. If the optional _outbuf_
21174 # argument is present, it must reference a String, which will receive the
21175 # data.
21176 # The <i>outbuf</i> will contain only the received data after the method call
21177 # even if it is not empty at the beginning.
21178 # It raises <code>EOFError</code> on end of file.
21179 # 
21180 # +readpartial+ is designed for streams such as pipes, sockets, and ttys. It
21181 # blocks only when no data is immediately available. This means that it
21182 # blocks only when following all conditions hold:
21183 # 
21184 # * The byte buffer in the +IO+ object is empty.
21185 # * The content of the stream is empty.
21186 # * The stream has not reached EOF.
21187 # 
21188 # When +readpartial+ blocks, it waits for data or EOF. If some data is read,
21189 # +readpartial+ returns with the data. If EOF is reached, readpartial raises
21190 # an +EOFError+.
21191 # 
21192 # When +readpartial+ doesn't block, it returns or raises immediately.  If
21193 # the byte buffer is not empty, it returns the data in the buffer. Otherwise, if
21194 # the stream has some content, it returns the data in the stream. If the
21195 # stream reaches EOF an +EOFError+ is raised.
21196 def readpartial(maxlen); ''; end
21197 ##
21198 # Reads at most _maxlen_ bytes from the ARGF stream in non-blocking mode.
21199 def read_nonblock(maxlen); ''; end
21200 ##
21201 # Reads +ARGF+'s current file in its entirety, returning an +Array+ of its
21202 # lines, one line per element. Lines are assumed to be separated by _sep_.
21203 # 
21204 #    lines = ARGF.readlines
21205 #    lines[0]                #=> "This is line one\n"
21206 def readlines(sep=$/); []; end
21207 ##
21208 # Reads +ARGF+'s current file in its entirety, returning an +Array+ of its
21209 # lines, one line per element. Lines are assumed to be separated by _sep_.
21210 # 
21211 #    lines = ARGF.readlines
21212 #    lines[0]                #=> "This is line one\n"
21213 def to_a(sep=$/); []; end
21214 ##
21215 # Returns the next line from the current file in +ARGF+.
21216 # 
21217 # By default lines are assumed to be separated by +$/+; to use a different
21218 # character as a separator, supply it as a +String+ for the _sep_ argument.
21219 # 
21220 # The optional  _limit_ argument specifies how many characters of each line
21221 # to return. By default all characters are returned.
21222 def gets(sep=$/); ''; end
21223 ##
21224 # Returns the next line from the current file in +ARGF+.
21225 # 
21226 # By default lines are assumed to be separated by +$/+; to use a different
21227 # character as a separator, supply it as a +String+ for the _sep_ argument.
21228 # 
21229 # The optional  _limit_ argument specifies how many characters of each line
21230 # to return. By default all characters are returned.
21231 # 
21232 # An +EOFError+ is raised at the end of the file.
21233 def readline(sep=$/); ''; end
21234 ##
21235 # Reads the next character from +ARGF+ and returns it as a +String+. Returns
21236 # +nil+ at the end of the stream.
21237 # 
21238 # +ARGF+ treats the files named on the command line as a single file created
21239 # by concatenating their contents. After returning the last character of the
21240 # first file, it returns the first character of the second file, and so on.
21241 # 
21242 # For example:
21243 # 
21244 #    $ echo "foo" > file
21245 #    $ ruby argf.rb file
21246 # 
21247 #    ARGF.getc  #=> "f"
21248 #    ARGF.getc  #=> "o"
21249 #    ARGF.getc  #=> "o"
21250 #    ARGF.getc  #=> "\n"
21251 #    ARGF.getc  #=> nil
21252 #    ARGF.getc  #=> nil
21253 def getc; '' || nil; end
21254 ##
21255 # Gets the next 8-bit byte (0..255) from +ARGF+. Returns +nil+ if called at
21256 # the end of the stream.
21257 # 
21258 # For example:
21259 # 
21260 #    $ echo "foo" > file
21261 #    $ ruby argf.rb file
21262 # 
21263 #    ARGF.getbyte #=> 102
21264 #    ARGF.getbyte #=> 111
21265 #    ARGF.getbyte #=> 111
21266 #    ARGF.getbyte #=> 10
21267 #    ARGF.getbyte #=> nil
21268 def getbyte; 0 || nil; end
21269 ##
21270 # Reads the next character from +ARGF+ and returns it as a +String+. Raises
21271 # an +EOFError+ after the last character of the last file has been read.
21272 # 
21273 # For example:
21274 # 
21275 #    $ echo "foo" > file
21276 #    $ ruby argf.rb file
21277 # 
21278 #    ARGF.readchar  #=> "f"
21279 #    ARGF.readchar  #=> "o"
21280 #    ARGF.readchar  #=> "o"
21281 #    ARGF.readchar  #=> "\n"
21282 #    ARGF.readchar  #=> end of file reached (EOFError)
21283 def readchar; '' || nil; end
21284 ##
21285 # Reads the next 8-bit byte from ARGF and returns it as a +Fixnum+. Raises
21286 # an +EOFError+ after the last byte of the last file has been read.
21287 # 
21288 # For example:
21289 # 
21290 #    $ echo "foo" > file
21291 #    $ ruby argf.rb file
21292 # 
21293 #    ARGF.readbyte  #=> 102
21294 #    ARGF.readbyte  #=> 111
21295 #    ARGF.readbyte  #=> 111
21296 #    ARGF.readbyte  #=> 10
21297 #    ARGF.readbyte  #=> end of file reached (EOFError)
21298 def readbyte; 0; end
21299 ##
21300 # Returns the current offset (in bytes) of the current file in +ARGF+.
21301 # 
21302 #    ARGF.pos    #=> 0
21303 #    ARGF.gets   #=> "This is line one\n"
21304 #    ARGF.pos    #=> 17
21305 def tell; 0; end
21306 ##
21307 # Returns the current offset (in bytes) of the current file in +ARGF+.
21308 # 
21309 #    ARGF.pos    #=> 0
21310 #    ARGF.gets   #=> "This is line one\n"
21311 #    ARGF.pos    #=> 17
21312 def pos; 0; end
21313 ##
21314 # Seeks to offset _amount_ (an +Integer+) in the +ARGF+ stream according to
21315 # the value of _whence_. See +IO#seek+ for further details.
21316 def seek(amount, whence=IO::SEEK_SET); 0; end
21317 ##
21318 # Positions the current file to the beginning of input, resetting
21319 # +ARGF.lineno+ to zero.
21320 # 
21321 #    ARGF.readline   #=> "This is line one\n"
21322 #    ARGF.rewind     #=> 0
21323 #    ARGF.lineno     #=> 0
21324 #    ARGF.readline   #=> "This is line one\n"
21325 def rewind; 0; end
21326 ##
21327 # Seeks to the position given by _position_ (in bytes) in +ARGF+.
21328 # 
21329 # For example:
21330 # 
21331 #     ARGF.pos = 17
21332 #     ARGF.gets   #=> "This is line two\n"
21333 def pos= position; 0; end
21334 ##
21335 # Returns true if the current file in +ARGF+ is at end of file, i.e. it has
21336 # no data to read. The stream must be opened for reading or an +IOError+
21337 # will be raised.
21338 # 
21339 #    $ echo "eof" | ruby argf.rb
21340 # 
21341 #    ARGF.eof?                 #=> false
21342 #    3.times { ARGF.readchar }
21343 #    ARGF.eof?                 #=> false
21344 #    ARGF.readchar             #=> "\n"
21345 #    ARGF.eof?                 #=> true
21346 def eof?; true || false; end
21347 ##
21348 # Returns true if the current file in +ARGF+ is at end of file, i.e. it has
21349 # no data to read. The stream must be opened for reading or an +IOError+
21350 # will be raised.
21351 # 
21352 #    $ echo "eof" | ruby argf.rb
21353 # 
21354 #    ARGF.eof?                 #=> false
21355 #    3.times { ARGF.readchar }
21356 #    ARGF.eof?                 #=> false
21357 #    ARGF.readchar             #=> "\n"
21358 #    ARGF.eof?                 #=> true
21359 def eof; true || false; end
21360 ##
21361 # Puts +ARGF+ into binary mode. Once a stream is in binary mode, it cannot
21362 # be reset to non-binary mode. This option has the following effects:
21363 # 
21364 # *  Newline conversion is disabled.
21365 # *  Encoding conversion is disabled.
21366 # *  Content is treated as ASCII-8BIT.
21367 def binmode; ARGF; end
21368 ##
21369 #  Returns true if +ARGF+ is being read in binary mode; false otherwise. (To
21370 #  enable binary mode use +ARGF.binmode+.
21371 # 
21372 # For example:
21373 # 
21374 #     ARGF.binmode?  #=> false
21375 #     ARGF.binmode
21376 #     ARGF.binmode?  #=> true
21377 def binmode?; true || false; end
21378 ##
21379 # Writes _string_ if inplace mode.
21380 def write(string); 0; end
21381 ##
21382 # Writes the given object(s) to <em>ios</em>. The stream must be
21383 # opened for writing. If the output field separator (<code>$,</code>)
21384 # is not <code>nil</code>, it will be inserted between each object.
21385 # If the output record separator (<code>$\\</code>)
21386 # is not <code>nil</code>, it will be appended to the output. If no
21387 # arguments are given, prints <code>$_</code>. Objects that aren't
21388 # strings will be converted by calling their <code>to_s</code> method.
21389 # With no argument, prints the contents of the variable <code>$_</code>.
21390 # Returns <code>nil</code>.
21391 # 
21392 #    $stdout.print("This is ", 100, " percent.\n")
21393 # 
21394 # <em>produces:</em>
21395 # 
21396 #    This is 100 percent.
21397 def print(); end
21398 ##
21399 # If <i>obj</i> is <code>Numeric</code>, write the character whose code is
21400 # the least-significant byte of <i>obj</i>, otherwise write the first byte
21401 # of the string representation of <i>obj</i> to <em>ios</em>. Note: This
21402 # method is not safe for use with multi-byte characters as it will truncate
21403 # them.
21404 # 
21405 #    $stdout.putc "A"
21406 #    $stdout.putc 65
21407 # 
21408 # <em>produces:</em>
21409 # 
21410 #    AA
21411 def putc(obj); Object.new; end
21412 ##
21413 # Writes the given objects to <em>ios</em> as with
21414 # <code>IO#print</code>. Writes a record separator (typically a
21415 # newline) after any that do not already end with a newline sequence.
21416 # If called with an array argument, writes each element on a new line.
21417 # If called without arguments, outputs a single record separator.
21418 # 
21419 #    $stdout.puts("this", "is", "a", "test")
21420 # 
21421 # <em>produces:</em>
21422 # 
21423 #    this
21424 #    is
21425 #    a
21426 #    test
21427 def puts(); end
21428 ##
21429 # Formats and writes to <em>ios</em>, converting parameters under
21430 # control of the format string. See <code>Kernel#sprintf</code>
21431 # for details.
21432 def printf(format_string , obj=0); end
21433 ##
21434 # Returns the current filename. "-" is returned when the current file is
21435 # STDIN.
21436 # 
21437 # For example:
21438 # 
21439 #    $ echo "foo" > foo
21440 #    $ echo "bar" > bar
21441 #    $ echo "glark" > glark
21442 # 
21443 #    $ ruby argf.rb foo bar glark
21444 # 
21445 #    ARGF.filename  #=> "foo"
21446 #    ARGF.read(5)   #=> "foo\nb"
21447 #    ARGF.filename  #=> "bar"
21448 #    ARGF.skip
21449 #    ARGF.filename  #=> "glark"
21450 def filename; ''; end
21451 ##
21452 # Returns the current filename. "-" is returned when the current file is
21453 # STDIN.
21454 # 
21455 # For example:
21456 # 
21457 #    $ echo "foo" > foo
21458 #    $ echo "bar" > bar
21459 #    $ echo "glark" > glark
21460 # 
21461 #    $ ruby argf.rb foo bar glark
21462 # 
21463 #    ARGF.filename  #=> "foo"
21464 #    ARGF.read(5)   #=> "foo\nb"
21465 #    ARGF.filename  #=> "bar"
21466 #    ARGF.skip
21467 #    ARGF.filename  #=> "glark"
21468 def path; ''; end
21469 ##
21470 # Returns the current file as an +IO+ or +File+ object. #<IO:<STDIN>> is
21471 # returned when the current file is STDIN.
21472 # 
21473 # For example:
21474 # 
21475 #    $ echo "foo" > foo
21476 #    $ echo "bar" > bar
21477 # 
21478 #    $ ruby argf.rb foo bar
21479 # 
21480 #    ARGF.file      #=> #<File:foo>
21481 #    ARGF.read(5)   #=> "foo\nb"
21482 #    ARGF.file      #=> #<File:bar>
21483 def file; IO.new || File.new; end
21484 ##
21485 #  Sets the current file to the next file in ARGV. If there aren't any more
21486 #  files it has no effect.
21487 # 
21488 # For example:
21489 # 
21490 #     $ ruby argf.rb foo bar
21491 #     ARGF.filename  #=> "foo"
21492 #     ARGF.skip
21493 #     ARGF.filename  #=> "bar"
21494 def skip; ARGF; end
21495 ##
21496 #  Closes the current file and skips to the next in the stream. Trying to
21497 #  close a file that has already been closed causes an +IOError+ to be
21498 #  raised.
21499 # 
21500 # For example:
21501 # 
21502 #     $ ruby argf.rb foo bar
21503 # 
21504 #     ARGF.filename  #=> "foo"
21505 #     ARGF.close
21506 #     ARGF.filename  #=> "bar"
21507 #     ARGF.close
21508 #     ARGF.close     #=> closed stream (IOError)
21509 def close; ARGF; end
21510 ##
21511 # Returns _true_ if the current file has been closed; _false_ otherwise. Use
21512 # +ARGF.close+ to actually close the current file.
21513 def closed?; true || false; end
21514 ##
21515 # Returns the current line number of ARGF as a whole. This value
21516 # can be set manually with +ARGF.lineno=+.
21517 # 
21518 # For example:
21519 # 
21520 #     ARGF.lineno   #=> 0
21521 #     ARGF.readline #=> "This is line 1\n"
21522 #     ARGF.lineno   #=> 1
21523 def lineno; 0; end
21524 ##
21525 # Sets the line number of +ARGF+ as a whole to the given +Integer+.
21526 # 
21527 # +ARGF+ sets the line number automatically as you read data, so normally
21528 # you will not need to set it explicitly. To access the current line number
21529 # use +ARGF.lineno+.
21530 # 
21531 # For example:
21532 # 
21533 #     ARGF.lineno      #=> 0
21534 #     ARGF.readline    #=> "This is line 1\n"
21535 #     ARGF.lineno      #=> 1
21536 #     ARGF.lineno = 0  #=> 0
21537 #     ARGF.lineno      #=> 0
21538 def lineno= integer; 0; end
21539 ##
21540 # Returns the file extension appended to the names of modified files under
21541 # inplace-edit mode. This value can be set using +ARGF.inplace_mode=+ or
21542 # passing the +-i+ switch to the Ruby binary.
21543 def inplace_mode; ''; end
21544 ##
21545 #  Sets the filename extension for inplace editing mode to the given String.
21546 #  Each file being edited has this value appended to its filename. The
21547 #  modified file is saved under this new name.
21548 # 
21549 #  For example:
21550 # 
21551 #      $ ruby argf.rb file.txt
21552 # 
21553 #      ARGF.inplace_mode = '.bak'
21554 #      ARGF.lines do |line|
21555 #        print line.sub("foo","bar")
21556 #      end
21557 # 
21558 # Each line of _file.txt_ has the first occurrence of "foo" replaced with
21559 # "bar", then the new line is written out to _file.txt.bak_.
21560 def inplace_mode= ext; ARGF; end
21561 ##
21562 #  Returns the external encoding for files read from +ARGF+ as an +Encoding+
21563 #  object. The external encoding is the encoding of the text as stored in a
21564 #  file. Contrast with +ARGF.internal_encoding+, which is the encoding used
21565 #  to represent this text within Ruby.
21566 # 
21567 #  To set the external encoding use +ARGF.set_encoding+.
21568 # 
21569 # For example:
21570 # 
21571 #     ARGF.external_encoding  #=>  #<Encoding:UTF-8>
21572 def external_encoding; Encoding.new; end
21573 ##
21574 # Returns the internal encoding for strings read from +ARGF+ as an
21575 # +Encoding+ object.
21576 # 
21577 # If +ARGF.set_encoding+ has been called with two encoding names, the second
21578 # is returned. Otherwise, if +Encoding.default_external+ has been set, that
21579 # value is returned. Failing that, if a default external encoding was
21580 # specified on the command-line, that value is used. If the encoding is
21581 # unknown, nil is returned.
21582 def internal_encoding; Encoding.new; end
21583 ##
21584 # If single argument is specified, strings read from ARGF are tagged with
21585 # the encoding specified.
21586 # 
21587 # If two encoding names separated by a colon are given, e.g. "ascii:utf-8",
21588 # the read string is converted from the first encoding (external encoding)
21589 # to the second encoding (internal encoding), then tagged with the second
21590 # encoding.
21591 # 
21592 # If two arguments are specified, they must be encoding objects or encoding
21593 # names. Again, the first specifies the external encoding; the second
21594 # specifies the internal encoding.
21595 # 
21596 # If the external encoding and the internal encoding are specified, the
21597 # optional +Hash+ argument can be used to adjust the conversion process. The
21598 # structure of this hash is explained in the +String#encode+ documentation.
21599 # 
21600 # For example:
21601 # 
21602 #     ARGF.set_encoding('ascii')         # Tag the input as US-ASCII text
21603 #     ARGF.set_encoding(Encoding::UTF_8) # Tag the input as UTF-8 text
21604 #     ARGF.set_encoding('utf-8','ascii') # Transcode the input from US-ASCII
21605 #                                        # to UTF-8.
21606 def set_encoding(ext_enc); ARGF; end
21607 end
21608 
21609 # The exception information message set by 'raise'. 
21610 $! = Exception.new
21611 
21612 # Array of backtrace of the last exception thrown.
21613 $@ = ['']
21614 
21615 # The string matched by the last successful match.
21616 $& = ''
21617 
21618 # The string to the left  of the last successful match.
21619 $` = ''
21620 
21621 # The string to the right of the last successful match.
21622 $' = ''
21623 
21624 # The highest group matched by the last successful match.
21625 $+ = ''
21626 
21627 # The information about the last match in the current scope.
21628 $~ = MatchData.new
21629 
21630 # The flag for case insensitive, nil by default.
21631 $= = true || false
21632 
21633 # The input record separator, newline by default.
21634 $/ = ''
21635 
21636 # The output record separator for the print and IO#write. Default is nil.
21637 $\ = ''
21638 
21639 # The output field separator for the print and Array#join.
21640 $, = ''
21641 
21642 # The default separator for String#split.
21643 $; = ''
21644 
21645 # The current input line number of the last file that was read.
21646 $. = 0
21647 
21648 # The virtual concatenation file of the files given on command line (or from $stdin if no files were given).
21649 $< = IO.new
21650 
21651 # The default output for print, printf. $stdout by default.
21652 $> = IO.new
21653 
21654 # The last input line of string by gets or readline.
21655 $_ = ''
21656 
21657 # Contains the name of the script being executed. May be assignable.
21658 $0 = ''
21659 
21660 # Command line arguments given for the script sans args.
21661 $* = ['']
21662 
21663 # The process number of the Ruby running this script.
21664 $$ = 0
21665 
21666 # The status of the last executed child process.
21667 $? = 0
21668 
21669 # Load path for scripts and binary modules by load or require.
21670 $: = ['']
21671 
21672 # The array contains the module names loaded by require.
21673 $" = ['']
21674 
21675 # The status of the -d switch.
21676 $DEBUG = true || false
21677 
21678 # Current input file from $<. Same as $<.filename.
21679 $FILENAME = ''
21680 
21681 # The alias to the $:.
21682 $LOAD_PATH = $:
21683 
21684 # The current standard error output.
21685 $stderr = IO.new
21686 
21687 # The current standard input.
21688 $stdin = IO.new
21689 
21690 # The current standard output.
21691 $stdout = IO.new
21692 
21693 # The verbose flag, which is set by the -v switch.
21694 $VERBOSE = true || false
21695 
21696 # The alias to $/.
21697 $-0 = $/
21698 
21699 # True if option -a is set. Read-only variable.
21700 $-a = true || false
21701 
21702 # The alias to $DEBUG.
21703 $-d = $DEBUG
21704 
21705 # The alias to $;.
21706 $-F = $;
21707 
21708 # In in-place-edit mode, this variable holds the extension, otherwise nil.
21709 $-i = nil
21710 
21711 # The alias to $:.
21712 $-I = $:
21713 
21714 # True if option -l is set. Read-only variable.
21715 $-l = true || false
21716 
21717 # True if option -p is set. Read-only variable.
21718 $-p = true || false
21719 
21720 # The alias to $VERBOSE.
21721 $-v = $VERBOSE
21722 
21723 # True if option -w is set.
21724 $-w = true || false
21725 
21726 # The typical true value.
21727 TRUE = true
21728 
21729 # The false itself.
21730 FALSE = false
21731 
21732 # The nil itself.
21733 NIL = nil
21734 
21735 # The standard input. The default value for $stdin.
21736 STDIN = $stdin
21737 
21738 # The standard output. The default value for $stdout.
21739 STDOUT = $stdout
21740 
21741 # The standard error output. The default value for $stderr.
21742 STDERR = $stderr
21743 
21744 # The hash contains current environment variables.
21745 ENV = {''=>''}
21746 
21747 # The alias to the $<.
21748 ARGF = $<
21749 
21750 # The alias to the $*.
21751 ARGV = $*
21752 
21753 # The file object of the script, pointing just after __END__.
21754 DATA = File.new
21755 
21756 # The ruby version string (VERSION was deprecated).
21757 RUBY_VERSION = ''
21758 
21759 # The release date string.
21760 RUBY_RELEASE_DATE = ''
21761 
21762 # The platform identifier.
21763 RUBY_PLATFORM = ''
21764