add RichString with toIntOpt method

Implementation taken from https://coderwall.com/p/lcxjzw