Module: RangesMergerUtils
- Included in:
- RangesMerger
- Defined in:
- lib/ranges_merger/ranges_merger_utils.rb
Instance Method Summary collapse
-
#array_to_ranges(_array) ⇒ Object
Convert Array of Arrays to Array of Ranges.
-
#normalize_array(_array) ⇒ Object
Convert Array of Arrays or Ranges to Array of Arrays.
Instance Method Details
#array_to_ranges(_array) ⇒ Object
Convert Array of Arrays to Array of Ranges
15 16 17 |
# File 'lib/ranges_merger/ranges_merger_utils.rb', line 15 def array_to_ranges(_array) _array.collect { |r| Range.new(r[0], r[1]) } end |
#normalize_array(_array) ⇒ Object
Convert Array of Arrays or Ranges to Array of Arrays
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ranges_merger/ranges_merger_utils.rb', line 3 def normalize_array(_array) klass = _array.first.class if klass.to_s == "Array" return self.merge_loop(_array) elsif klass.to_s == "Range" return _array.collect { |a| [a.first, a.last] } else return [] end end |