class String
Extensions to class String
. @author Thorsten Kummerow (@thomerow)
Public Instance Methods
remove_first_and_last()
click to toggle source
Removes the first and last characters from a string and returns the manipulated string. @return [String] The string without its first and last characters.
# File lib/core_ext/string.rb, line 21 def remove_first_and_last if self.length == 0 then return '' end result = self.dup result[0] = '' if result.length > 0 then result[result.length - 1] = '' end return result end