Class: Sergovia::Fingering
- Inherits:
-
Object
- Object
- Sergovia::Fingering
- Defined in:
- lib/sergovia/fingering.rb
Instance Attribute Summary collapse
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#playability ⇒ Object
readonly
Returns the value of attribute playability.
Instance Method Summary collapse
-
#initialize(notes:, playability: nil) ⇒ Fingering
constructor
A new instance of Fingering.
- #to_tab ⇒ Object
Constructor Details
#initialize(notes:, playability: nil) ⇒ Fingering
Returns a new instance of Fingering.
5 6 7 8 |
# File 'lib/sergovia/fingering.rb', line 5 def initialize(notes:, playability: nil) @notes = notes @playability = playability end |
Instance Attribute Details
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
3 4 5 |
# File 'lib/sergovia/fingering.rb', line 3 def notes @notes end |
#playability ⇒ Object (readonly)
Returns the value of attribute playability.
3 4 5 |
# File 'lib/sergovia/fingering.rb', line 3 def playability @playability end |
Instance Method Details
#to_tab ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sergovia/fingering.rb', line 10 def to_tab (1..6).map do |i| @notes.select { |note| note.string == i }.first || Note.new(fret: ' x', string: i, pitch: nil) end.sort_by(&:string).map do |note| if note.fret == " x" note.fret else "%2d" % note.fret end end end |