class Note
Constants
- ACCIDENTALS
- MUTED
Attributes
name[R]
position[R]
to_s[R]
Public Class Methods
find(name)
click to toggle source
# File lib/chord_finder/note.rb, line 10 def self.find(name) JOIN_SCALE.find_note(name) end
new(name, position = nil)
click to toggle source
# File lib/chord_finder/note.rb, line 20 def initialize(name, position = nil) @name = name == MUTED ? name : convert_name(name) @position = position end
Public Instance Methods
+(steps)
click to toggle source
# File lib/chord_finder/note.rb, line 29 def +(steps) SHARPS_SCALE[position + steps] end
==(other_note)
click to toggle source
# File lib/chord_finder/note.rb, line 25 def ==(other_note) position == other_note.position end
muted?()
click to toggle source
# File lib/chord_finder/note.rb, line 33 def muted? name == MUTED end
Private Instance Methods
convert_name(name)
click to toggle source
# File lib/chord_finder/note.rb, line 38 def convert_name(name) raise ArgumentError.new("You must enter a valid note name.") unless valid?(name) name[0].upcase + ACCIDENTALS[name[1]] end
valid?(name)
click to toggle source
# File lib/chord_finder/note.rb, line 43 def valid?(name) !!(name =~ /^[a-gA-G][#!b_]?$/) end