Method: Array#range_containing

Defined in:
lib/openc3/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!

Parameters:

  • The start value to search for (must be less than end_value)

  • The end value to search for

Returns:

  • The range of array elements which contain both the start_value and end_value



208
209
210
211
212
# File 'lib/openc3/core_ext/array.rb', line 208

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