No commit activity in last 3 years
No release in over 3 years
RandomAccessible mixin provides all methods of Array (regard as high-functioning edition of Enumerable). As a class includes Enumerable must provide "each" method, a class includes RandomAccessible must have some methods. Please see the document for detail.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme
= random-accessible

RandomAccessible mixin provides all methods of Array to your classes (regard as high-functioning edition of Enumerable).
As Enumerable mixin requests "each" method, RandomAccessible requests methods below.
- size (same as Array#size)
- read_access (similar to Array#[])
- replace_access (similar to Array#[]=)
- shrink (similar to Array#pop)

size method returns the number of objects which the object contains.
Note that this method must behave same as Array's.

read_access(pos) is similar to Array#[]. But the module guarantees that the argument is an Integer larger than or equal 0 and less than its size.

replace_access(pos, val) is similar to Array#[]=. The module guarantees that the argument pos is an Integer and 0 <= pos < size.

shrink is similar to Array#pop. But the method can return anything.

== Installation

gem install random-accessible

== Limitation

Behavior of RandomAccessible#eql? is different from Array's.
The method always returns false if the argument does not include RandomReadable (RandomAccessible includes RandomReadable). Also note that Array#eql? returns false if the arguent is RandomAccessible.

== License

This library is distributed under the dual license of the Ruby license (in the narrow sense) and the 2-clause BSD license. Please see http://www.ruby-lang.org and BSDL.
Copyright (c) 2011, Natsuki Kawai.