Class: Coltrane::Theory::ScaleSet
- Inherits:
-
Object
- Object
- Coltrane::Theory::ScaleSet
- Extended by:
- Forwardable
- Defined in:
- lib/coltrane/theory/scale_set.rb
Instance Attribute Summary collapse
-
#scales ⇒ Object
Returns the value of attribute scales.
-
#searched_notes ⇒ Object
Returns the value of attribute searched_notes.
Instance Method Summary collapse
- #full_names ⇒ Object
-
#initialize(*scales, searched_notes: nil) ⇒ ScaleSet
constructor
A new instance of ScaleSet.
- #names ⇒ Object
- #results ⇒ Object
- #strict_scales ⇒ Object
Constructor Details
#initialize(*scales, searched_notes: nil) ⇒ ScaleSet
Returns a new instance of ScaleSet.
9 10 11 12 |
# File 'lib/coltrane/theory/scale_set.rb', line 9 def initialize(*scales, searched_notes: nil) @scales = scales.uniq @searched_notes = searched_notes end |
Instance Attribute Details
#scales ⇒ Object
Returns the value of attribute scales.
7 8 9 |
# File 'lib/coltrane/theory/scale_set.rb', line 7 def scales @scales end |
#searched_notes ⇒ Object
Returns the value of attribute searched_notes.
7 8 9 |
# File 'lib/coltrane/theory/scale_set.rb', line 7 def searched_notes @searched_notes end |
Instance Method Details
#full_names ⇒ Object
35 36 37 |
# File 'lib/coltrane/theory/scale_set.rb', line 35 def full_names map(&:full_name) end |
#names ⇒ Object
31 32 33 |
# File 'lib/coltrane/theory/scale_set.rb', line 31 def names map(&:name) end |
#results ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/coltrane/theory/scale_set.rb', line 20 def results raise 'No searched notes were provided' unless searched_notes @table ||= scales.each_with_object({}) do |scale, the_table| the_table[scale.name] ||= {} the_table[scale.name][scale.tone.pitch_class.name] = ( scale.notes & searched_notes ) end end |
#strict_scales ⇒ Object
14 15 16 17 18 |
# File 'lib/coltrane/theory/scale_set.rb', line 14 def strict_scales @strict_scales ||= scales.select do |scale| (scale.notes & searched_notes).size == searched_notes.size end end |