I often find myself checking if some value belongs to some set. As I understand, people normally use Enumerable#member? for this.
Enumerable#member?
end_index = [\
Unless you are dealing with elements that have special meaning for === like modules, regexes, etc., you can do pretty much well with case.
===
case
end_index = case word[-1]; when '.', ','; -3 else -2 end