Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Overview
Extensions to class String.
Instance Method Summary collapse
-
#remove_first_and_last ⇒ String
Removes the first and last characters from a string and returns the manipulated string.
Instance Method Details
#remove_first_and_last ⇒ String
Removes the first and last characters from a string and returns the manipulated string.
21 22 23 24 25 26 27 |
# 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 |