Method: Array#range_within
- Defined in:
- lib/openc3/core_ext/array.rb
#range_within(start_value, end_value) ⇒ Range
Returns the range of array elements which within both the start value and end value.
NOTE: This routine only works on sorted data!
224 225 226 227 228 229 230 231 |
# File 'lib/openc3/core_ext/array.rb', line 224 def range_within(start_value, end_value) raise "end_value: #{end_value} must be greater than start_value: #{start_value}" if end_value < start_value range = Range.new(index_gt_eq(start_value), index_lt_eq(end_value)) # Sometimes we get a backwards range so check for that and reverse it range = Range.new(range.last, range.first) if range.last < range.first range end |