Class: Sergovia::Fingering

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#notesObject (readonly)

Returns the value of attribute notes.



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

def notes
  @notes
end

#playabilityObject (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_tabObject



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