I am writing a class, Wrapper
, and am giving it a class method self.wrap
. I am getting an unexpected end-of-input
error. I have been staring at the code forever and can't see where the mistake might be. I think I have all of my end
's in place. What am I missing?
require 'pry'
class Wrapper
def self.wrap(input_string, column_number)
position = 0
num_inserted = 0
while (position + column_number < line.length) do
last_space_index = input_string.rindex(" ", position + column_number)
if last_space_index > position - 1
input_string[num_inserted + last_space_index] = "\n"
else
input_string.insert(num_inserted + position + column_number, "\n")
position += column_number
num_inserted ++
end
end
end
end