Module: MTK::Groups

Defined in:
lib/mtk.rb,
lib/mtk/groups/chord.rb,
lib/mtk/groups/melody.rb,
lib/mtk/groups/collection.rb,
lib/mtk/groups/pitch_class_set.rb,
lib/mtk/groups/pitch_collection.rb

Overview

Collections of Core objects

Defined Under Namespace

Modules: Collection, PitchCollection Classes: Chord, Melody, PitchClassSet

Class Method Summary collapse

Class Method Details

.to_pitch_classes(*anything) ⇒ Object

MTK::Groups



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/mtk/groups/collection.rb', line 168

def to_pitch_classes(*anything)
  anything = anything.first if anything.length == 1
  if anything.respond_to? :to_pitch_classes
    anything.to_pitch_classes
  else
    case anything
      when ::Enumerable then anything.map{|item| MTK.PitchClass(item) }
      else [MTK.PitchClass(anything)]
    end
  end
end

.to_pitches(*anything) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/mtk/groups/collection.rb', line 182

def to_pitches(*anything)
  anything = anything.first if anything.length == 1
  if anything.respond_to? :to_pitches
    anything.to_pitches
  else
    case anything
      when ::Enumerable then anything.map{|item| MTK.Pitch(item) }
      else [MTK.Pitch(anything)]
    end
  end
end