Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/array/subindex.rb,
lib/array/subindex/version.rb

Defined Under Namespace

Modules: Subindex

Instance Method Summary collapse

Instance Method Details

#[](index, length = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/array/subindex.rb', line 4

def [](index, length=nil)
  case index.class.to_s.to_sym
  when :Range
    fetch_range(index)
  when :Float, :Rational
    fetch_subindex(index)
  else
    fetch_integer_index(index, length)
  end
end