class Array

Extensions to Array needed to support flex array.

Public Instance Methods

array_data() click to toggle source

Quick access to the array data for internal use.

# File lib/flex_array/array.rb, line 15
def array_data
  self
end
array_specs() click to toggle source

Quick access to the limits for internal use.

# File lib/flex_array/array.rb, line 10
def array_specs
  SpecArray.new([0...self.length])
end
limits() click to toggle source

Get the specifications of the array index values.

# File lib/flex_array/array.rb, line 5
def limits
  [0...self.length]
end
to_flex_array() click to toggle source

Return this flex array as a flex array!

# File lib/flex_array/array.rb, line 36
def to_flex_array
  FlexArray.new_from_array(self)
end
to_index_range(spec) click to toggle source

Convert this array to an range index against the spec.

# File lib/flex_array/array.rb, line 20
def to_index_range(spec)
  spec_max = spec.max

  self.collect do |value|
    value = Integer(value)
    value = spec_max + value + 1 if value < 0

    unless spec === value
      fail IndexError, "Subscript invalid or out of range: #{self.inspect}"
    end

    value
  end
end