| Class | NotesCollection |
| In: |
app/models/notes_collection.rb
|
| Parent: | Object |
NotesCollection represents a collection of notes. Using this collection, you can determine chord and scale/mode matches in specific or all keys. This class is currently under heavily development and will eventually be home to heavy logic involved in associating an arbitrary collection of notes with chords, given that some scales tone may be "omitable", etc.
Creating the collection of notes should be done by indexing the Notes class directly with a comma-separated string of notes.
Will only do exact 100% match of notes given and notes in chords. No fuzzyness such as the ability to omit the root and other non-important tones. Does not yet find supersets or subsets.
NotesCollection['C, E, G, A'].chords.symbols # => "Amin7, Cmaj6"
NotesCollection['C, E, G, A'].in_key_of('A').chords.symbols
# => "Amin7"
| new | -> | [] |
| invalid_keys | [RW] | |
| keys | [RW] |
# File app/models/notes_collection.rb, line 39
39: def initialize(value = [])
40: @value_as_given = value
41: @keys = []
42: @invalid_keys = []
43:
44: value = value.split(/,| /).map(&:strip) if value.instance_of?(String)
45: value.each do |key_name|
46: key_object = Key[key_name]
47:
48: if key_object.nil?
49: @invalid_keys << key_name
50: else
51: @keys << key_object
52: end
53: end
54: end