Class: ColtraneInstruments::Guitar::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/coltrane_instruments/guitar/base.rb

Overview

A base class for operations involving Guitars

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tuning = DEFAULT_TUNING, frets = DEFAULT_FRETS) ⇒ Base

Returns a new instance of Base.



20
21
22
23
24
25
26
# File 'lib/coltrane_instruments/guitar/base.rb', line 20

def initialize(tuning = DEFAULT_TUNING, frets = DEFAULT_FRETS)
  @strings = tuning.map do |p|
    String.new(Coltrane::Pitch[p], guitar: self)
  end

  @frets = frets
end

Instance Attribute Details

#fretsObject (readonly)

Returns the value of attribute frets.



9
10
11
# File 'lib/coltrane_instruments/guitar/base.rb', line 9

def frets
  @frets
end

#stringsObject (readonly)

Returns the value of attribute strings.



9
10
11
# File 'lib/coltrane_instruments/guitar/base.rb', line 9

def strings
  @strings
end

Class Method Details

.find_chords(target_chord) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/coltrane_instruments/guitar/base.rb', line 11

def self.find_chords(target_chord)
  unless target_chord.is_a?(Coltrane::Chord)
    target_chord = Coltrane::Chord.new(name: target_chord)
  end

  ColtraneInstruments::Guitar::Chord.new(target_chord, guitar: new)
                                    .fetch_descendant_chords
end