E - the type of elementspublic final class RubyRange<E> extends RubyEnumerable<E> implements java.io.Serializable
RubyRange is inspired by the Range class of Ruby. It does not exactly
follow the implementation of Ruby, especially on the range of alphanumeric
strings. All objects can use the RubyRange to create a range of
interval. As long as it provides the corresponding Successive object.
RubyRange is also a Ruby.Enumerable.
| Constructor and Description |
|---|
RubyRange(Successive<E> successive,
E startPoint,
E endPoint)
Creates a
RubyRange of given elements. |
| Modifier and Type | Method and Description |
|---|---|
E |
begin()
Returns the beginning of this
RubyRange. |
boolean |
coverʔ(E item)
Check if an item is within this
RubyRange. |
RubyRange<E> |
each(Block<? super E> block)
Yields each element to the block.
|
E |
end()
Returns the end of this
RubyRange. |
boolean |
eqlʔ(java.lang.Object o)
Equivalent to
equals(Object). |
boolean |
equals(java.lang.Object o) |
protected java.lang.Iterable<E> |
getIterable()
Returns an Iterable of elements.
|
int |
hash()
Equivalent to
hashCode(). |
int |
hashCode() |
boolean |
includeʔ(E item)
Checks if target element is included.
|
java.lang.String |
inspect()
Equivalent to
toString(). |
E |
last()
Returns the end of this
RubyRange. |
RubyArray<E> |
last(int n)
Returns the last n elements of this
RubyRange. |
boolean |
memberʔ(E item)
Equivalent to
RubyContract.Enumerable.includeʔ(Object). |
RubyEnumerator<E> |
step(int n)
Creates a
RubyEnumerator by all nth elements of the range. |
RubyRange<E> |
step(int n,
Block<E> block)
Iterates over this
RubyRange and yields each nth element to the
block. |
java.lang.String |
toS()
Equivalent to
toString(). |
java.lang.String |
toString() |
allʔ, allʔ, anyʔ, anyʔ, chunk, chunk, collect, collect, collect, collectConcat, collectConcat, count, count, cycle, cycle, cycle, cycle, detect, detect, drop, dropWhile, dropWhile, each, eachCons, eachCons, eachEntry, eachEntry, eachSlice, eachSlice, eachWithIndex, eachWithIndex, eachWithObject, eachWithObject, entries, find, find, findAll, findAll, findIndex, findIndex, findIndex, first, first, flatMap, flatMap, grep, grep, grep, groupBy, groupBy, groupBy, inject, inject, inject, inject, iterator, lazy, map, map, map, max, max, maxBy, maxBy, maxBy, maxBy, min, min, minBy, minBy, minBy, minBy, minmax, minmax, minmaxBy, minmaxBy, minmaxBy, minmaxBy, noneʔ, noneʔ, oneʔ, oneʔ, partition, partition, reduce, reduce, reduce, reduce, reject, reject, reverseEach, reverseEach, select, select, sliceBefore, sliceBefore, sort, sortBy, sortBy, sortBy, sortBy, sortBy, take, takeWhile, takeWhile, toA, zip, zip, zippublic RubyRange(Successive<E> successive, E startPoint, E endPoint)
RubyRange of given elements.successive - a Successive object to provide the successor of elementsstartPoint - where the range beginsendPoint - where the range endsjava.lang.NullPointerException - if successive is nulljava.lang.IllegalArgumentException - if startPoint or endPoint is nullprotected java.lang.Iterable<E> getIterable()
RubyEnumerablegetIterable in class RubyEnumerable<E>public E begin()
RubyRange.RubyRangepublic boolean coverʔ(E item)
RubyRange.item - to be checkedpublic RubyRange<E> each(Block<? super E> block)
each in interface Ruby.Enumerable<E>each in interface RubyContract.Enumerable<E,Ruby.Enumerator<?>,RubyArray<?>>each in class RubyEnumerable<E>block - to yield each elementRubyRangepublic boolean eqlʔ(java.lang.Object o)
equals(Object).o - any Objectpublic int hash()
hashCode().public boolean includeʔ(E item)
RubyContract.Enumerableincludeʔ in interface RubyContract.Enumerable<E,Ruby.Enumerator<?>,RubyArray<?>>includeʔ in class RubyEnumerable<E>item - to be searchedpublic java.lang.String inspect()
toString().public RubyArray<E> last(int n)
RubyRange.n - number of elementsRubyArraypublic boolean memberʔ(E item)
RubyContract.EnumerableRubyContract.Enumerable.includeʔ(Object).memberʔ in interface RubyContract.Enumerable<E,Ruby.Enumerator<?>,RubyArray<?>>memberʔ in class RubyEnumerable<E>item - to be foundpublic RubyEnumerator<E> step(int n)
RubyEnumerator by all nth elements of the range.n - interval to stepRubyEnumeratorpublic RubyRange<E> step(int n, Block<E> block)
RubyRange and yields each nth element to the
block.n - interval to stepblock - to yield each elementRubyRangepublic java.lang.String toS()
toString().public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class RubyEnumerable<E>