Method: Array#range_containing
- Defined in:
- lib/cosmos/core_ext/array.rb
#range_containing(start_value, end_value) ⇒ Range
Returns the range of array elements which contain both the start value and end value.
NOTE: This routine only works on sorted data!
191 192 193 194 |
# File 'lib/cosmos/core_ext/array.rb', line 191 def range_containing(start_value, end_value) raise "end_value: #{end_value} must be greater than start_value: #{start_value}" if end_value < start_value Range.new(index_lt_eq(start_value), index_gt_eq(end_value)) end |