Module: Chords::NoteClassMethods
- Defined in:
- lib/chords/note.rb
Overview
E.g. E + 3 => G
Instance Method Summary collapse
Instance Method Details
#+(interval) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/chords/note.rb', line 44 def +(interval) note = NOTES.detect{|n| [n].flatten.include?(self.to_s.gsub(/^.*::/, ''))} idx = NOTES.index(note) + interval idx = idx % NOTES.size Chords.const_get [NOTES[idx]].flatten.first end |
#-(interval) ⇒ Object
50 |
# File 'lib/chords/note.rb', line 50 def -(interval); self + (-interval) end |
#title ⇒ Object
51 |
# File 'lib/chords/note.rb', line 51 def title; self.to_s.gsub(/^.*::/, '').sub('s', '#') end |