Recipe 1.6. Converting Between Characters and Values
To see the ASCII code for a specific character as an integer, use the ? operator:
1
puts ?a

Output: 97
To see the integer value of a particular in a string, access it as though it were an element of an array:
1
puts 'bad'[2]

Output: 100
To see the ASCII character corresponding to a given number, call its #chr method. This returns a string containing only one character:
1 puts 98.chr
Output: b