Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/flex_array/object.rb
Overview
Extensions to Object needed to support flex array.
Instance Method Summary collapse
-
#to_index_range(spec) ⇒ Object
Convert this object to an range index against the spec.
-
#to_spec_component(_stride) ⇒ Object
Fail with message since the array dimension is invalid.
Instance Method Details
#to_index_range(spec) ⇒ Object
Convert this object to an range index against the spec.
Parameters
-
spec - The spec component used to validate this index.
Returns
-
A range.
Exceptions
-
IndexError if the range is not valid.
19 20 21 22 23 24 25 |
# File 'lib/flex_array/object.rb', line 19 def to_index_range(spec) if self == :all spec.range else fail IndexError, "Invalid subscript: #{self.inspect}" end end |
#to_spec_component(_stride) ⇒ Object
Fail with message since the array dimension is invalid.
Parameters
-
_stride - unused, required to maintain signature.
Returns
-
Nothing, always fails.
8 9 10 |
# File 'lib/flex_array/object.rb', line 8 def to_spec_component(_stride) fail ArgumentError, "Invalid flex array dimension: #{self.inspect}" end |