class SpecArray
This helper class encapsulates an array of flex array spec components.
Attributes
spec_count[R]
The number of elements defined by this array specification.
Public Class Methods
new(array_specs)
click to toggle source
Create a flex array specification.
Calls superclass method
# File lib/flex_array/spec_array.rb, line 11 def initialize(array_specs) super(0) @spec_count = 1 #Parse the array limits. array_specs.reverse_each do |spec| self.insert(0, spec.to_spec_component(@spec_count)) @spec_count *= self[0].span end self end
Public Instance Methods
enlarge(growth)
click to toggle source
Enlarge the flex array along its first dimension.
# File lib/flex_array/spec_array.rb, line 37 def enlarge(growth) self[0].enlarge(growth) #Compute the new size. @spec_count = self.inject(1) {|product, element| product*element.span} end
transposed?()
click to toggle source
Is this array specification transposed in any way?
# File lib/flex_array/spec_array.rb, line 25 def transposed? check = 1 self.reverse_each do |component| return true unless check == component.stride check *= component.span end false end