Class: Sergovia::Chord

Inherits:
Object
  • Object
show all
Defined in:
lib/sergovia/chord.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fretsObject

Returns the value of attribute frets.



3
4
5
# File 'lib/sergovia/chord.rb', line 3

def frets
  @frets
end

#pitchesObject

Returns the value of attribute pitches.



3
4
5
# File 'lib/sergovia/chord.rb', line 3

def pitches
  @pitches
end

#tuningObject

Returns the value of attribute tuning.



3
4
5
# File 'lib/sergovia/chord.rb', line 3

def tuning
  @tuning
end

Instance Method Details

#fingeringsObject



11
12
13
# File 'lib/sergovia/chord.rb', line 11

def fingerings
  Transcriber.new(tuning: tuning, frets: frets).fingerings(@pitch_string)
end

#to_tabObject



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