org.jruby
Class RubyRange

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

public class RubyRange
extends RubyObject

Author:
jpetersen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer
 
Field Summary
 
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
RubyRange(Ruby runtime, RubyClass impl)
           
 
Method Summary
 long[] begLen(long len, int err)
           
static RubyClass createRangeClass(Ruby runtime)
           
 IRubyObject doClone()
           
 IRubyObject each(Block block)
           
 IRubyObject eql_p(IRubyObject other)
           
 IRubyObject equal(IRubyObject other, Block block)
           
 RubyBoolean exclude_end_p()
           
 IRubyObject first()
           
 long[] getBeginLength(long limit, boolean truncate, boolean isStrict)
          Converts this Range to a pair of integers representing a start position and length.
 RubyFixnum hash()
           
 RubyBoolean include_p(IRubyObject obj, Block block)
           
 void init(IRubyObject aBegin, IRubyObject aEnd, RubyBoolean aIsExclusive)
           
 IRubyObject initialize(IRubyObject[] args, Block unusedBlock)
           
 IRubyObject inspect(Block block)
           
 IRubyObject last()
           
 RubyFixnum length(Block block)
           
static RubyRange newRange(Ruby runtime, IRubyObject begin, IRubyObject end, boolean isExclusive)
           
 IRubyObject step(IRubyObject[] args, Block block)
           
 IRubyObject to_s(Block block)
           
 
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, dup, eql, eqlInternal, equal, equalInternal, equals, evalSimple, evalUnder, evalWithBinding, extend, freeze, frozen, getInstanceVariable, getInstanceVariables, getInstanceVariablesSnapshot, getJavaClass, getMetaClass, getNativeTypeIndex, getRuntime, getSingletonClass, getSingletonClassClone, getType, hashCode, id_deprecated, id, infectBy, inherited, initCopy, initialize_copy, inspect, 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, toString, trueFalseNil, trueFalseNil, type_deprecated, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RubyRange

public RubyRange(Ruby runtime,
                 RubyClass impl)
Method Detail

init

public void init(IRubyObject aBegin,
                 IRubyObject aEnd,
                 RubyBoolean aIsExclusive)

doClone

public IRubyObject doClone()
Overrides:
doClone in class RubyObject

createRangeClass

public static RubyClass createRangeClass(Ruby runtime)

getBeginLength

public long[] getBeginLength(long limit,
                             boolean truncate,
                             boolean isStrict)
Converts this Range to a pair of integers representing a start position and length. If either of the range's endpoints is negative, it is added to the limit parameter in an attempt to arrive at a position p such that 0 <= p <= limit. If truncate is true, the result will be adjusted, if possible, so that begin + length <= limit. If strict is true, an exception will be raised if the range can't be converted as described above; otherwise it just returns null.

Parameters:
limit - the size of the object (e.g., a String or Array) that this range is being evaluated against.
truncate - if true, result must fit within the range (0..limit).
isStrict - if true, raises an exception if the range can't be converted.
Returns:
a two-element array representing a start value and a length, or null if the conversion failed.

begLen

public long[] begLen(long len,
                     int err)

newRange

public static RubyRange newRange(Ruby runtime,
                                 IRubyObject begin,
                                 IRubyObject end,
                                 boolean isExclusive)

initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block unusedBlock)
Overrides:
initialize in class RubyObject

first

public IRubyObject first()

last

public IRubyObject last()

hash

public RubyFixnum hash()
Overrides:
hash in class RubyObject

inspect

public IRubyObject inspect(Block block)

to_s

public IRubyObject to_s(Block block)

exclude_end_p

public RubyBoolean exclude_end_p()

length

public RubyFixnum length(Block block)

equal

public IRubyObject equal(IRubyObject other,
                         Block block)

eql_p

public IRubyObject eql_p(IRubyObject other)

each

public IRubyObject each(Block block)

step

public IRubyObject step(IRubyObject[] args,
                        Block block)

include_p

public RubyBoolean include_p(IRubyObject obj,
                             Block block)


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