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 sharp',
    'D flat'
  ],
  3 => 'D',
  4 => [
    'D sharp',
    'E flat'
  ],
  5 => 'E',
  6 => 'F',
  7 => [
    'F sharp',
    'G flat'
  ],
  8 => 'G',
  9 => [
    'G sharp',
    'A flat'
  ],
  10 => 'A',
  11 => [
    'A sharp',
    'B flat'
  ],
  12 => 'B'
}.freeze

Class Method Summary collapse

Class Method Details

.all(sharp_or_flat = :sharp, formated: false) ⇒ Object



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

def self.all(sharp_or_flat = :sharp, formated: false)
  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

    if formated
      Fretboard::Note.formated(result)
    else
      result
    end
  end
end

.firstObject



59
60
61
# File 'lib/fretboard/notes.rb', line 59

def self.first
  all.first
end