class String def begin?(other_str) self.index(other_str) == 0 end def end?(other_str) i = self.rindex(other_str) return false if i.nil? return (self.length == i + other_str.length) end def concat_sep(other_str, sep) return if ! other_str self.concat(sep) if ! empty? self.concat(other_str) end end