Class: Sergovia::Chord
- Inherits:
-
Object
- Object
- Sergovia::Chord
- Defined in:
- lib/sergovia/chord.rb
Instance Attribute Summary collapse
-
#frets ⇒ Object
Returns the value of attribute frets.
-
#pitches ⇒ Object
Returns the value of attribute pitches.
-
#tuning ⇒ Object
Returns the value of attribute tuning.
Instance Method Summary collapse
- #fingerings ⇒ Object
-
#initialize(pitch_string, tuning: STANDARD_TUNING, frets: 24) ⇒ Chord
constructor
A new instance of Chord.
- #to_tab ⇒ Object
Constructor Details
#initialize(pitch_string, tuning: STANDARD_TUNING, frets: 24) ⇒ Chord
Returns a new instance of Chord.
5 6 7 8 9 |
# File 'lib/sergovia/chord.rb', line 5 def initialize(pitch_string, tuning: STANDARD_TUNING, frets: 24) @pitch_string = pitch_string @tuning = tuning @frets = frets end |
Instance Attribute Details
#frets ⇒ Object
Returns the value of attribute frets.
3 4 5 |
# File 'lib/sergovia/chord.rb', line 3 def frets @frets end |
#pitches ⇒ Object
Returns the value of attribute pitches.
3 4 5 |
# File 'lib/sergovia/chord.rb', line 3 def pitches @pitches end |
#tuning ⇒ Object
Returns the value of attribute tuning.
3 4 5 |
# File 'lib/sergovia/chord.rb', line 3 def tuning @tuning end |
Instance Method Details
#fingerings ⇒ Object
11 12 13 |
# File 'lib/sergovia/chord.rb', line 11 def fingerings Transcriber.new(tuning: tuning, frets: frets).fingerings(@pitch_string) end |
#to_tab ⇒ Object
15 16 17 |
# File 'lib/sergovia/chord.rb', line 15 def to_tab fingerings.select{ |f| f.playability > 0.0 }.map(&:to_tab).transpose.map { |string| string.join("--") }.join("\n") end |