Skip to content

Instantly share code, notes, and snippets.

@cgcardona
Created December 7, 2010 16:37
Show Gist options
  • Save cgcardona/732015 to your computer and use it in GitHub Desktop.
Save cgcardona/732015 to your computer and use it in GitHub Desktop.
Massive Ruby Case Statement
def quick_note(note)
case note
when "a0"
"#{note} = 0"
when "a#0"
"#{note} = 1"
when "b0"
"#{note} = 2"
when "c1"
"#{note} = 3"
when "c#1"
"#{note} = 4"
when "d1"
"#{note} = 5"
when "d#1"
"#{note} = 6"
when "e1"
"#{note} = 7"
when "f1"
"#{note} = 8"
when "f#1"
"#{note} = 9"
when "g1"
"#{note} = 10"
when "g#1"
"#{note} = 11"
when "a1"
"#{note} = 12"
when "a#1"
"#{note} = 13"
when "b1"
"#{note} = 14"
when "c2"
"#{note} = 15"
when "c#2"
"#{note} = 16"
when "d2"
"#{note} = 17"
when "d#2"
"#{note} = 18"
when "e2"
"#{note} = 19"
when "f2"
"#{note} = 20"
when "f#2"
"#{note} = 21"
when "g2"
"#{note} = 22"
when "g#2"
"#{note} = 23"
when "a2"
"#{note} = 24"
when "a#2"
"#{note} = 25"
when "b2"
"#{note} = 26"
when "c3"
"#{note} = 27"
when "c#3"
"#{note} = 28"
when "d3"
"#{note} = 29"
when "d#3"
"#{note} = 30"
when "e3"
"#{note} = 31"
when "f3"
"#{note} = 32"
when "f#3"
"#{note} = 33"
when "g3"
"#{note} = 34"
when "g#3"
"#{note} = 35"
when "a3"
"#{note} = 36"
when "a#3"
"#{note} = 37"
when "b3"
"#{note} = 38"
when "c4"
"#{note} = 39"
when "c#4"
"#{note} = 40"
when "d4"
"#{note} = 41"
when "d#4"
"#{note} = 42"
when "e4"
"#{note} = 43"
when "f4"
"#{note} = 44"
when "f#4"
"#{note} = 45"
when "g4"
"#{note} = 46"
when "g#4"
"#{note} = 47"
when "a4"
"#{note} = 48"
when "a#4"
"#{note} = 49"
when "b4"
"#{note} = 50"
when "c5"
"#{note} = 51"
when "c#5"
"#{note} = 52"
when "d5"
"#{note} = 53"
when "d#5"
"#{note} = 54"
when "e5"
"#{note} = 55"
when "f5"
"#{note} = 56"
when "f#5"
"#{note} = 57"
when "g5"
"#{note} = 58"
when "g#5"
"#{note} = 59"
when "a5"
"#{note} = 60"
when "a#5"
"#{note} = 61"
when "b5"
"#{note} = 62"
when "c6"
"#{note} = 63"
when "c#6"
"#{note} = 64"
when "d6"
"#{note} = 65"
when "d#6"
"#{note} = 66"
when "e6"
"#{note} = 67"
when "f6"
"#{note} = 68"
when "f#6"
"#{note} = 69"
when "g6"
"#{note} = 70"
when "g#6"
"#{note} = 71"
when "a6"
"#{note} = 72"
when "a#6"
"#{note} = 73"
when "b6"
"#{note} = 74"
when "c7"
"#{note} = 75"
when "c#7"
"#{note} = 76"
when "d7"
"#{note} = 77"
when "d#7"
"#{note} = 78"
when "e7"
"#{note} = 79"
when "f7"
"#{note} = 80"
when "f#7"
"#{note} = 81"
when "g7"
"#{note} = 82"
when "g#7"
"#{note} = 83"
when "a7"
"#{note} = 84"
when "a#7"
"#{note} = 85"
when "b7"
"#{note} = 86"
when "c8"
"#{note} = 87"
when 0
"#{note} = a0"
when 1
"#{note} = a#0"
when 2
"#{note} = b0"
when 3
"#{note} = c1"
when 4
"#{note} = c#1"
when 5
"#{note} = d1"
when 6
"#{note} = d#1"
when 7
"#{note} = e1"
when 8
"#{note} = f1"
when 9
"#{note} = f#1"
when 10
"#{note} = g1"
when 11
"#{note} = g#1"
when 12
"#{note} = a1"
when 13
"#{note} = a#1"
when 14
"#{note} = b1"
when 15
"#{note} = c2"
when 16
"#{note} = c#2"
when 17
"#{note} = d2"
when 18
"#{note} = d#2"
when 19
"#{note} = e2"
when 20
"#{note} = f2"
when 21
"#{note} = f#2"
when 22
"#{note} = g2"
when 23
"#{note} = g#2"
when 24
"#{note} = a2"
when 25
"#{note} = a#2"
when 26
"#{note} = b2"
when 27
"#{note} = c3"
when 28
"#{note} = c#3"
when 29
"#{note} = d3"
when 30
"#{note} = d#3"
when 31
"#{note} = e3"
when 32
"#{note} = f3"
when 33
"#{note} = f#3"
when 34
"#{note} = g3"
when 35
"#{note} = g#3"
when 36
"#{note} = a3"
when 37
"#{note} = a#3"
when 38
"#{note} = b3"
when 39
"#{note} = c4"
when 40
"#{note} = c#4"
when 41
"#{note} = d4"
when 42
"#{note} = d#4"
when 43
"#{note} = e4"
when 44
"#{note} = f4"
when 45
"#{note} = f#4"
when 46
"#{note} = g4"
when 47
"#{note} = g#4"
when 48
"#{note} = a4"
when 49
"#{note} = a#4"
when 50
"#{note} = b4"
when 51
"#{note} = c5"
when 52
"#{note} = c#5"
when 53
"#{note} = d5"
when 54
"#{note} = d#5"
when 55
"#{note} = e5"
when 56
"#{note} = f5"
when 57
"#{note} = f#5"
when 58
"#{note} = g5"
when 59
"#{note} = g#5"
when 60
"#{note} = a5"
when 61
"#{note} = a#5"
when 62
"#{note} = b5"
when 63
"#{note} = c6"
when 64
"#{note} = c#6"
when 65
"#{note} = d6"
when 66
"#{note} = d#6"
when 67
"#{note} = e6"
when 68
"#{note} = f6"
when 69
"#{note} = f#6"
when 70
"#{note} = g6"
when 71
"#{note} = g#6"
when 72
"#{note} = a6"
when 73
"#{note} = a#6"
when 74
"#{note} = b6"
when 75
"#{note} = c7"
when 76
"#{note} = c#7"
when 77
"#{note} = d7"
when 78
"#{note} = d#7"
when 79
"#{note} = e7"
when 80
"#{note} = f7"
when 81
"#{note} = f#7"
when 82
"#{note} = g7"
when 83
"#{note} = g#7"
when 84
"#{note} = a7"
when 85
"#{note} = a#7"
when 86
"#{note} = b7"
when 87
"#{note} = c8"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment