I know this question is a fundamental one. I am able to take user input for a string and for an integer using:
str = gets()
num = gets().to_i
But I want to read from the String(say which is in my case more than a line in length) character by character and count the number of characters from the first to the very last for every character encountered in the string. I know this can be achieved through:
str.length
I want to count it character wise as I am trying to implement word wrap in Ruby, wherein say within the line width(which would be a user defined number input) I would want to print only those words which are not continuing over to the next line i.e. I don't want to split a continuous word over two lines. Such words should be taken to the new line.
Thanks for you time..!!