I am trying to assign an integer to multiple characters in a string.
def userinput(input)
@user = input.upcase.delete('^A-Z').chars.each_slice(5).map(&:join)
end
=> userinput("This is test to convert multiple characters in a string")
=> ["THISI","STEST","TOCON", "VERTM", "ULTIP", "LECHA", "RACTE", "RSINA", "STRIN", "G"]
After getting this array, I want to assign an integer for each character in the string, so I tried something like this ...
=> @user.map {|ch| ch.ord - 'A'.ord + 1}
Unfortunately, I only get the corresponding alphabet integer for the first letter.
=> [20, 19, 20, 22, 21, 12, 18, 18, 19, 7]
I would really appreciate it if someone could give me a hint on how to assign the remaining 4 remaining letters of each line so that the result would be something like this:
=> ["ABCDE", "ABCDE"]
=> [12345, 12345]