Package org.jruby
Class RubyRange
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyRange
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprivate static classprivate static interfaceprivate static classprivate static classNested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IRubyObjectprivate static final byte[]private IRubyObjectprivate static final RubyRange.InspectRecursiveprivate booleanprivate booleanprivate booleanprivate static final ObjectMarshalFields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, UNTRUST_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbegin(ThreadContext context) (package private) final long[]begLen(long len, int err) (package private) final longbegLen0(long len) (package private) final longbegLen1(long len, long beg) (package private) final int[]begLenInt(int len, int err) (package private) final booleancheckBegin(long length) private IRubyObjectcheckStepDomain(ThreadContext context, IRubyObject step, String method) voidLots of MRI objects keep their state in non-lookupable ivars (e:g.cover_p(ThreadContext context, IRubyObject obj) private booleancoverRange(ThreadContext context, RubyRange val) static RubyClasscreateRangeClass(Ruby runtime) private static booleandiscreteObject(ThreadContext context, IRubyObject obj) each(ThreadContext context, Block block) each19(ThreadContext context, Block block) Deprecated.end(ThreadContext context) eql_p(ThreadContext context, IRubyObject other) eqq_p(ThreadContext context, IRubyObject obj) private IRubyObjectequalityInner(ThreadContext context, IRubyObject other, MethodNames equalityCheck) first(ThreadContext context) first(ThreadContext context, IRubyObject arg) private voidfixnumEach(ThreadContext context, Block block) private voidfixnumStep(ThreadContext context, Ruby runtime, long step, Block block) hash()rb_obj_id Will return the hash code of this object.hash(ThreadContext context) include_p(ThreadContext context, IRubyObject obj) include_p19(ThreadContext context, IRubyObject obj) Deprecated.private IRubyObjectincludeCommon(ThreadContext context, IRubyObject val, boolean useStringCover) private voidinit(ThreadContext context, IRubyObject begin, IRubyObject end, boolean isExclusive) initialize(ThreadContext context, IRubyObject[] args, Block unusedBlock) initialize_copy(ThreadContext context, IRubyObject original) inspect()rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj.inspect(ThreadContext context) private static RubyStringinspectValue(ThreadContext context, IRubyObject value) final booleanstatic booleanisRangeLike(ThreadContext context, IRubyObject obj, RespondToCallSite respond_to_begin, RespondToCallSite respond_to_end) Return true if the given object responds to "begin" and "end" methods.static booleanisRangeLike(ThreadContext context, IRubyObject obj, JavaSites.CheckedSites begin_checked, JavaSites.CheckedSites end_checked, JavaSites.CheckedSites exclude_end_checked) Return true if the given object responds to "begin", "end" and "exclude_end?" methods.private static booleanisZero(IRubyObject num) last(ThreadContext context) last(ThreadContext context, IRubyObject arg) private static booleanlinearObject(ThreadContext context, IRubyObject obj) max(ThreadContext context, Block block) max(ThreadContext context, IRubyObject arg, Block block) min(ThreadContext context, Block block) min(ThreadContext context, IRubyObject arg, Block block) static RubyRangenewExclusiveRange(ThreadContext context, IRubyObject begin, IRubyObject end) static RubyRangenewInclusiveRange(ThreadContext context, IRubyObject begin, IRubyObject end) static RubyRangenewRange(ThreadContext context, IRubyObject begin, IRubyObject end, boolean isExclusive) private voidnumericStep(ThreadContext context, Ruby runtime, IRubyObject step, Block block) op_equal(ThreadContext context, IRubyObject other) rb_obj_equal Will by default use identity equality to compare objects.op_mod(ThreadContext context, IRubyObject step) static IRubyObjectrangeBeginLength(ThreadContext context, IRubyObject range, int len, int[] begLen, int err) private static IRubyObjectrangeBeginLengthError(ThreadContext context, int beg, int end, boolean excludeEnd, int err) private voidrangeEach(ThreadContext context, RubyRange.RangeCallBack callback) static RubyRangerangeFromRangeLike(ThreadContext context, IRubyObject rangeLike, CallSite beginSite, CallSite endSite, CallSite excludeEndSite) Given a range-line object that response to "begin", "end", construct a proper range by calling those methods and "exclude_end?" with the given call sites.private booleanrangeIncludes(ThreadContext context, IRubyObject val) private static IRubyObjectrangeLe(ThreadContext context, IRubyObject a, IRubyObject b) private static intrangeLess(ThreadContext context, IRubyObject a, IRubyObject b) private static IRubyObjectrangeLt(ThreadContext context, IRubyObject a, IRubyObject b) private static JavaSites.RangeSitessites(ThreadContext context) size(ThreadContext context) private static IRubyObjectsize(ThreadContext ctx, RubyRange recv, IRubyObject[] args) A size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])step(ThreadContext context, Block block) step(ThreadContext context, IRubyObject step, Block block) step19(ThreadContext context, Block block) Deprecated.step19(ThreadContext context, IRubyObject step, Block block) Deprecated.private IRubyObjectstepCommon(ThreadContext context, IRubyObject step, Block block) private IRubyObjectstepEnumeratorize(ThreadContext context, IRubyObject step, String method) private static IRubyObjectstepSize(ThreadContext context, RubyRange self, IRubyObject[] args) A step size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[])to_a(ThreadContext context, Block block) to_s()rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj.private RubyStringto_s(ThreadContext context) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, dig1, dig2, eqlInternal, equalInternal, equals, getNativeClassIndex, hashCode, inspect, op_eqq, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, defaultToJava, display, dup, ensureInstanceVariablesSettable, eql, eql_p, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, infectBy, infectBy, initialize, initialize_copy, initialize19, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method, method_missing, method_missing19, method19, methods, methods, methods19, methodsImpl, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal_19, op_match, op_match19, op_not, op_not_equal, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, rbClone, rbInspect, recacheBuiltinMethods, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted, tainted_p, testFrozen, testFrozen, to_a, to_a, toJava, trust, type, type_deprecated, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
-
Field Details
-
begin
-
end
-
isExclusive
private boolean isExclusive -
isEndless
private boolean isEndless -
isInited
private boolean isInited -
INSPECT_RECURSIVE
-
DOTDOTDOT
private static final byte[] DOTDOTDOT -
RANGE_MARSHAL
-
-
Constructor Details
-
RubyRange
-
-
Method Details
-
createRangeClass
-
newRange
public static RubyRange newRange(ThreadContext context, IRubyObject begin, IRubyObject end, boolean isExclusive) -
newInclusiveRange
public static RubyRange newInclusiveRange(ThreadContext context, IRubyObject begin, IRubyObject end) -
newExclusiveRange
public static RubyRange newExclusiveRange(ThreadContext context, IRubyObject begin, IRubyObject end) -
copySpecialInstanceVariables
Description copied from class:RubyBasicObjectLots of MRI objects keep their state in non-lookupable ivars (e:g. Range, Struct, etc). This method is responsible for dupping our java field equivalents- Specified by:
copySpecialInstanceVariablesin interfaceIRubyObject- Overrides:
copySpecialInstanceVariablesin classRubyBasicObject
-
checkBegin
final boolean checkBegin(long length) -
begLen
final long[] begLen(long len, int err) -
begLen0
final long begLen0(long len) -
begLen1
final long begLen1(long len, long beg) -
begLenInt
final int[] begLenInt(int len, int err) -
init
-
initialize
-
initialize_copy
-
hash
Description copied from class:RubyBasicObjectrb_obj_id Will return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.- Overrides:
hashin classRubyBasicObject
-
hash
-
inspectValue
-
inspect
Description copied from class:RubyBasicObjectrb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj. If not overridden, uses theto_smethod to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin classRubyBasicObject- Returns:
- String
-
inspect
-
to_s
Description copied from class:RubyBasicObjectrb_any_to_s call-seq: obj.to_s => string Returns a string representing obj. The defaultto_sprints the object's class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns ``main.''- Overrides:
to_sin classRubyBasicObject
-
to_s
-
to_s
-
exclude_end_p
-
eql_p
-
op_equal
Description copied from class:RubyBasicObjectrb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems- Specified by:
op_equalin interfaceIRubyObject- Overrides:
op_equalin classRubyBasicObject
-
equalityInner
private IRubyObject equalityInner(ThreadContext context, IRubyObject other, MethodNames equalityCheck) -
isZero
-
rangeLt
-
rangeLess
-
rangeLe
-
rangeEach
-
coverRange
-
to_a
-
each19
Deprecated. -
each
-
fixnumEach
-
step19
Deprecated. -
step19
Deprecated. -
step
-
step
-
checkStepDomain
-
stepEnumeratorize
-
op_mod
-
stepCommon
-
fixnumStep
-
numericStep
-
size
A size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[]) -
stepSize
A step size method suitable for lambda method reference implementation ofRubyEnumerator.SizeFn.size(ThreadContext, IRubyObject, IRubyObject[]) -
include_p19
Deprecated. -
include_p
-
includeCommon
-
discreteObject
-
linearObject
-
eqq_p
-
cover_p
-
rangeIncludes
-
min
-
max
-
min
-
max
-
first
-
begin
-
first
-
last
-
end
-
last
-
size
-
isExcludeEnd
public final boolean isExcludeEnd() -
rangeFromRangeLike
public static RubyRange rangeFromRangeLike(ThreadContext context, IRubyObject rangeLike, CallSite beginSite, CallSite endSite, CallSite excludeEndSite) Given a range-line object that response to "begin", "end", construct a proper range by calling those methods and "exclude_end?" with the given call sites.- Parameters:
context- current contextrangeLike- range-like objectbeginSite- "begin" call siteendSite- "end" call siteexcludeEndSite- "exclude_end?" call site- Returns:
- a proper Range based on the results of calling those methods
-
isRangeLike
public static boolean isRangeLike(ThreadContext context, IRubyObject obj, RespondToCallSite respond_to_begin, RespondToCallSite respond_to_end) Return true if the given object responds to "begin" and "end" methods.- Parameters:
context- current contextobj- possibly range-like objectrespond_to_begin- respond_to? site for beginrespond_to_end- respond_to? site for end- Returns:
-
isRangeLike
public static boolean isRangeLike(ThreadContext context, IRubyObject obj, JavaSites.CheckedSites begin_checked, JavaSites.CheckedSites end_checked, JavaSites.CheckedSites exclude_end_checked) Return true if the given object responds to "begin", "end" and "exclude_end?" methods.- Parameters:
context- current contextobj- possibly range-like objectbegin_checked- checked site for beginend_checked- checked site for endexclude_end_checked- checked site for exclude_end?- Returns:
-
rangeBeginLength
public static IRubyObject rangeBeginLength(ThreadContext context, IRubyObject range, int len, int[] begLen, int err) -
rangeBeginLengthError
private static IRubyObject rangeBeginLengthError(ThreadContext context, int beg, int end, boolean excludeEnd, int err) -
sites
-