Class: Coltrane::Representation::Guitar::NoteSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/coltrane/representation/guitar/note_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(note_set, guitar:) ⇒ NoteSet

Returns a new instance of NoteSet.



13
14
15
16
# File 'lib/coltrane/representation/guitar/note_set.rb', line 13

def initialize(note_set, guitar:)
  @notes  = note_set
  @guitar = guitar
end

Instance Attribute Details

#guitarObject (readonly)

Returns the value of attribute guitar.



10
11
12
# File 'lib/coltrane/representation/guitar/note_set.rb', line 10

def guitar
  @guitar
end

#notesObject (readonly)

Returns the value of attribute notes.



10
11
12
# File 'lib/coltrane/representation/guitar/note_set.rb', line 10

def notes
  @notes
end

Instance Method Details

#resultsObject Also known as: strings



20
21
22
23
24
25
26
27
28
29
# File 'lib/coltrane/representation/guitar/note_set.rb', line 20

def results
  @strings ||= begin
    guitar.strings.map do |string|
      {
        pitch: string.pitch,
        notes: notes.map { |note| string.find(note) }
      }
    end
  end
end