Class: Fretboard::Notes

Inherits:
Object
  • Object
show all
Defined in:
lib/fretboard/notes.rb

Constant Summary collapse

BASIS_NOTES =

Fretboard::Notes.all(:both) Fretboard::Notes.all(:sharp) Fretboard::Notes.all(:flat)

{
  1 => 'C',
  2 => [
    'C#',
    'Db'
  ],
  3 => 'D',
  4 => [
    'D#',
    'Eb'
  ],
  5 => 'E',
  6 => 'F',
  7 => [
    'F#',
    'Gb'
  ],
  8 => 'G',
  9 => [
    'G#',
    'Ab'
  ],
  10 => 'A',
  11 => [
    'A#',
    'Bb'
  ],
  12 => 'B'
}.freeze

Class Method Summary collapse

Class Method Details

.all(sharp_or_flat = :sharp) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fretboard/notes.rb', line 37

def self.all(sharp_or_flat = :sharp)
  BASIS_NOTES.map do |_key, value|
    result = value

    if value.is_a?(Array)
      result = if sharp_or_flat == :both
                 value.join('/')
               elsif sharp_or_flat == :sharp
                 value.first
               else
                 value.last
               end
    end

    result
  end
end

.firstObject



55
56
57
# File 'lib/fretboard/notes.rb', line 55

def self.first
  all.first
end