Method: Musa::Datasets::Score#subset
- Defined in:
- lib/musa-dsl/datasets/score.rb
#subset {|dataset| ... } ⇒ Score
Creates filtered subset of score.
Returns new Score containing only events matching the condition.
446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/musa-dsl/datasets/score.rb', line 446 def subset raise ArgumentError, "subset needs a block with the inclusion condition on the dataset" unless block_given? filtered_score = Score.new @score.each_pair do |time, datasets| datasets.each do |dataset| filtered_score.at time, add: dataset if yield(dataset) end end filtered_score end |