lib/coltrane_instruments/guitar/note.rb in coltrane-2.0.0 vs lib/coltrane_instruments/guitar/note.rb in coltrane-2.1.0
- old
+ new
@@ -1,8 +1,24 @@
# frozen_string_literal: true
module ColtraneInstruments
module Guitar
class Note
+ attr_reader :string, :fret
+
+ def initialize(string, fret = nil)
+ @string = string
+ @fret = fret
+ end
+
+ def pitch
+ string + fret unless fret.nil?
+ end
+
+ def pitch_class
+ pitch.pitch_class unless fret.nil?
+ end
+
+ alias note pitch_class
end
end
end