org.jruby
Class RubyFile

java.lang.Object
  extended by org.jruby.RubyObject
      extended by org.jruby.RubyIO
          extended by org.jruby.RubyFile
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject

public class RubyFile
extends RubyIO

Ruby File class equivalent in java.

Author:
jpetersen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer
 
Field Summary
static int LOCK_EX
           
static int LOCK_NB
           
static int LOCK_SH
           
static int LOCK_UN
           
protected  java.lang.String path
           
 
Fields inherited from class org.jruby.RubyIO
fileno, handler, isOpen, lineNumber, modes, STDERR, STDIN, STDOUT
 
Fields inherited from class org.jruby.RubyObject
instanceVariables, isTrue, metaClass, NEVER, OBJECT_ALLOCATOR
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyFile(Ruby runtime, RubyClass type)
           
RubyFile(Ruby runtime, java.lang.String path)
           
RubyFile(Ruby runtime, java.lang.String path, java.io.Reader reader)
           
 
Method Summary
static IRubyObject basename(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject chmod(IRubyObject arg)
           
static IRubyObject chmod(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject chown(IRubyObject arg)
           
static IRubyObject chown(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject close()
          Closes all open resources for the IO.
static RubyClass createFileClass(Ruby runtime)
           
static IRubyObject dirname(IRubyObject recv, IRubyObject arg)
           
static IRubyObject expand_path(IRubyObject recv, IRubyObject[] args)
          Converts a pathname to an absolute pathname.
static IRubyObject extname(IRubyObject recv, IRubyObject arg)
          Returns the extension name of the file.
 IRubyObject flock(IRubyObject lockingConstant)
           
static IRubyObject fnmatch(IRubyObject recv, IRubyObject[] args)
          Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing.
 IRubyObject initialize(IRubyObject[] args, Block block)
           
 IRubyObject inspect()
          rb_obj_inspect
static RubyString join(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject lstat(IRubyObject recv, IRubyObject filename)
           
 IRubyObject mtime()
           
static IRubyObject mtime(IRubyObject recv, IRubyObject filename)
           
static IRubyObject open(IRubyObject recv, IRubyObject[] args, Block block)
           
static IRubyObject open(IRubyObject recv, IRubyObject[] args, boolean tryToYield, Block block)
           
 void openInternal(java.lang.String newPath, IOModes newModes)
           
 RubyString path()
           
static IRubyObject rename(IRubyObject recv, IRubyObject oldName, IRubyObject newName)
           
static IRubyObject size_p(IRubyObject recv, IRubyObject filename)
           
static RubyArray split(IRubyObject recv, IRubyObject arg)
           
 IRubyObject stat()
           
static IRubyObject symlink_p(IRubyObject recv, IRubyObject arg1)
           
static IRubyObject symlink(IRubyObject recv, IRubyObject from, IRubyObject to)
           
 java.lang.String toString()
           
 IRubyObject truncate(IRubyObject arg)
           
static IRubyObject truncate(IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject unlink(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject utime(IRubyObject recv, IRubyObject[] args)
          This method does NOT set atime, only mtime, since Java doesn't support anything else.
 
Methods inherited from class org.jruby.RubyIO
addString, binmode, checkReadable, checkWriteable, closed, closeWrite, createIOClass, each_byte, each_line, eof, fcntl, fdOpen, fileno, flush, foreach, fsync, getBlocking, getc, getChannel, getInStream, getIOHandlerByFileno, getNewFileno, getOutStream, gets, hasPendingBuffered, initialize_copy, internalGets, io_wait, isOpen, lineno_set, lineno, pid, pipe, popen, pos_set, pos, print, printf, putc, puts, read, read, readchar, readline, readlines, readlines, readpartial, ready, registerIOHandler, reopen, rewind, seek, select_static, select, sync_set, sync, sysread, syswrite, to_io, tty, ungetc, unregisterIOHandler, write
 
Methods inherited from class org.jruby.RubyObject
addFinalizer, anyToString, asString, asSymbol, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethodMissing, callMethodMissing, callSuper, checkArrayType, checkFrozen, checkStringType, compilerCallMethod, compilerCallMethodWithIndex, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToString, convertToType, convertToType, convertToType, convertToTypeWithCheck, createObjectClass, dataGetStruct, dataWrapStruct, display, doClone, dup, eql, eqlInternal, equal, equalInternal, equals, evalSimple, evalUnder, evalWithBinding, extend, freeze, frozen, getInstanceVariable, getInstanceVariables, getInstanceVariablesSnapshot, getJavaClass, getMetaClass, getNativeTypeIndex, getRuntime, getSingletonClass, getSingletonClassClone, getType, hash, hashCode, id_deprecated, id, infectBy, inherited, initCopy, instance_eval, instance_exec, instance_of, instance_variable_get, instance_variable_set, instance_variables, instanceVariableNames, isFalse, isFrozen, isImmediate, isKindOf, isNil, isSingleton, isTaint, isTrue, kind_of, makeMetaClass, match, method, methods, nil_p, obj_equal, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, respond_to, respondsTo, safeGetInstanceVariables, safeHasInstanceVariables, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, singleton_methods, specificEval, taint, tainted, testFrozen, to_s, trueFalseNil, trueFalseNil, type_deprecated, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCK_SH

public static final int LOCK_SH
See Also:
Constant Field Values

LOCK_EX

public static final int LOCK_EX
See Also:
Constant Field Values

LOCK_NB

public static final int LOCK_NB
See Also:
Constant Field Values

LOCK_UN

public static final int LOCK_UN
See Also:
Constant Field Values

path

protected java.lang.String path
Constructor Detail

RubyFile

public RubyFile(Ruby runtime,
                RubyClass type)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path,
                java.io.Reader reader)
Method Detail

createFileClass

public static RubyClass createFileClass(Ruby runtime)

openInternal

public void openInternal(java.lang.String newPath,
                         IOModes newModes)

close

public IRubyObject close()
Description copied from class: RubyIO

Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.

Overrides:
close in class RubyIO
Returns:
The IO.

flock

public IRubyObject flock(IRubyObject lockingConstant)

initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block block)
Overrides:
initialize in class RubyIO

chmod

public IRubyObject chmod(IRubyObject arg)

chown

public IRubyObject chown(IRubyObject arg)

mtime

public IRubyObject mtime()

path

public RubyString path()

stat

public IRubyObject stat()

truncate

public IRubyObject truncate(IRubyObject arg)

toString

public java.lang.String toString()
Overrides:
toString in class RubyIO

inspect

public IRubyObject inspect()
Description copied from class: RubyObject
rb_obj_inspect

Specified by:
inspect in interface IRubyObject
Overrides:
inspect in class RubyObject
Returns:
String

basename

public static IRubyObject basename(IRubyObject recv,
                                   IRubyObject[] args)

chmod

public static IRubyObject chmod(IRubyObject recv,
                                IRubyObject[] args)

chown

public static IRubyObject chown(IRubyObject recv,
                                IRubyObject[] args)

dirname

public static IRubyObject dirname(IRubyObject recv,
                                  IRubyObject arg)

extname

public static IRubyObject extname(IRubyObject recv,
                                  IRubyObject arg)
Returns the extension name of the file. An empty string is returned if the filename (not the entire path) starts or ends with a dot.

Parameters:
recv -
arg - Path to get extension name of
Returns:
Extension, including the dot, or an empty string

expand_path

public static IRubyObject expand_path(IRubyObject recv,
                                      IRubyObject[] args)
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless a second argument is given, in which case it will be used as the starting point. If the second argument is also relative, it will first be converted to an absolute pathname.

Parameters:
recv -
args -
Returns:
Resulting absolute path as a String

fnmatch

public static IRubyObject fnmatch(IRubyObject recv,
                                  IRubyObject[] args)
Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *: Glob - match any sequence chars (re: .*). If like begins with '.' then it doesn't. ?: Matches a single char (re: .). [set]: Matches a single char in a set (re: [...]).


join

public static RubyString join(IRubyObject recv,
                              IRubyObject[] args)

lstat

public static IRubyObject lstat(IRubyObject recv,
                                IRubyObject filename)

mtime

public static IRubyObject mtime(IRubyObject recv,
                                IRubyObject filename)

open

public static IRubyObject open(IRubyObject recv,
                               IRubyObject[] args,
                               Block block)

open

public static IRubyObject open(IRubyObject recv,
                               IRubyObject[] args,
                               boolean tryToYield,
                               Block block)

rename

public static IRubyObject rename(IRubyObject recv,
                                 IRubyObject oldName,
                                 IRubyObject newName)

size_p

public static IRubyObject size_p(IRubyObject recv,
                                 IRubyObject filename)

split

public static RubyArray split(IRubyObject recv,
                              IRubyObject arg)

symlink

public static IRubyObject symlink(IRubyObject recv,
                                  IRubyObject from,
                                  IRubyObject to)

symlink_p

public static IRubyObject symlink_p(IRubyObject recv,
                                    IRubyObject arg1)

truncate

public static IRubyObject truncate(IRubyObject recv,
                                   IRubyObject arg1,
                                   IRubyObject arg2)

utime

public static IRubyObject utime(IRubyObject recv,
                                IRubyObject[] args)
This method does NOT set atime, only mtime, since Java doesn't support anything else.


unlink

public static IRubyObject unlink(IRubyObject recv,
                                 IRubyObject[] args)


Copyright © 2002-2007 JRuby Team. All Rights Reserved.