Module: Musa::Extension::ExplodeRanges
- Defined in:
- lib/musa-dsl/core-ext/array-explode-ranges.rb
Overview
Note:
This refinement must be activated with using Musa::Extension::ExplodeRanges
Refinement that expands Range objects within arrays into their constituent elements.
This is particularly useful in musical contexts where arrays may contain both individual values and ranges (like MIDI note ranges or channel ranges), and you need to work with the fully expanded list.
Use Cases
- Expanding MIDI channel specifications: [0, 2..4, 7] → [0, 2, 3, 4, 7]
- Expanding note ranges in chord definitions
- Processing mixed literal and range values in musical parameters
- Any scenario where ranges need to be flattened for iteration
Methods Added
Array
- Array#explode_ranges - Expands all Range objects in the array into their individual elements