org.jruby
Class RubyRange

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

public class RubyRange
extends RubyObject

Version:
$Revision: 1.6 $
Author:
jpetersen

Field Summary
 
Fields inherited from class org.jruby.RubyObject
runtime
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyRange(Ruby ruby)
           
 
Method Summary
static RubyClass createRangeClass(Ruby ruby)
           
 IRubyObject each()
           
 RubyBoolean equal(IRubyObject obj)
          rb_obj_equal
 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.
 void init(IRubyObject begin, IRubyObject end, RubyBoolean isExclusive)
           
 IRubyObject initialize(IRubyObject[] args)
           
 RubyString inspect()
          rb_obj_inspect
 IRubyObject last()
           
 RubyFixnum length()
           
static RubyRange newRange(Ruby ruby, IRubyObject begin, IRubyObject end, boolean isExclusive)
           
 RubyBoolean op_eqq(IRubyObject obj)
           
 
Methods inherited from class org.jruby.RubyObject
argCount, asSymbol, callbackFactory, callInit, callMethod, callMethod, callMethod, checkSafeString, convertToString, convertToType, convertType, createObjectClass, defineSingletonMethod, display, dup, equals, eval, eval, evalUnder, extend, extendObject, freeze, frozen, getInstanceVariable, getInstanceVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getType, hash, hashCode, hasInstanceVariable, id, infectBy, instance_eval, instance_of, instance_variables, instanceVariableNames, isFalse, isFrozen, isKindOf, isNil, isTaint, isTrue, kind_of, makeMetaClass, marshalTo, method_missing, method, methods, nilObject, private_methods, protected_methods, rbClone, removeInstanceVariable, respond_to, respondsTo, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, setupClone, singleton_methods, singletonMethodsAllowed, specificEval, taint, tainted, to_a, to_s, toString, type, untaint
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RubyRange

public RubyRange(Ruby ruby)
Method Detail

init

public void init(IRubyObject begin,
                 IRubyObject end,
                 RubyBoolean isExclusive)

createRangeClass

public static RubyClass createRangeClass(Ruby ruby)

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.

newRange

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

initialize

public IRubyObject initialize(IRubyObject[] args)

first

public IRubyObject first()

last

public IRubyObject last()

inspect

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

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

exclude_end_p

public RubyBoolean exclude_end_p()

length

public RubyFixnum length()

equal

public RubyBoolean equal(IRubyObject obj)
Description copied from class: RubyObject
rb_obj_equal

Overrides:
equal in class RubyObject

op_eqq

public RubyBoolean op_eqq(IRubyObject obj)

each

public IRubyObject each()


Copyright © 2002 Jan Arne Petersen. All Rights Reserved.