Method: String#suffix
- Defined in:
- lib/casual_support/string/suffix.rb
#suffix(affix) ⇒ String
Appends affix
to the String only if the String does not already end with affix
. Otherwise returns a duplicate of the String. Equivalent to gsub(/(?<!affix)$/, “affix”).
13 14 15 |
# File 'lib/casual_support/string/suffix.rb', line 13 def suffix(affix) self.end_with?(affix) ? self.dup : "#{self}#{affix}" end |