class Integer
Extensions to Integer
needed to support flex array.
Public Instance Methods
to_index_range(spec)
click to toggle source
Convert this integer to a range index against the spec.
# File lib/flex_array/integer.rb, line 14 def to_index_range(spec) alter_ego = (self >= 0) ? self : (spec.max + self + 1) if spec === alter_ego alter_ego..alter_ego else fail IndexError, "Subscript out of range: #{self.inspect}" end end
to_spec_component(stride)
click to toggle source
Convert this integer to a limits component.
# File lib/flex_array/integer.rb, line 5 def to_spec_component(stride) if self >= 0 SpecComponent.new(0...self, stride) else fail ArgumentError, "Invalid flex array dimension: #{self.inspect}" end end