Module: EnumerableStrings
- Included in
- ArrayOfStrings
- Defined in
- lib/kyanite/enumerable/enumerable_strings.rb
Enumeration Of Strings
- Kyanite definitions
- Kyanite class with module included
- Kyanite tests and examples
- Usage
-
require 'kyanite/enumerable/enumerable_strings'
Instance Method Summary (collapse)
-
- (Object) palindrom_rumpf
Delete every element from the front with is identical with the back -- leave the significant middle part.
Instance Method Details
- (Object) palindrom_rumpf
Delete every element from the front with is identical with the back -- leave the significant middle part. Example:
['lut', 'lutm', 'lutmi', 'lutmil', 'lutmila', 'lutrika', 'lutrik', 'lutri', 'lutr', 'lut'].palindrom_rumpf =>
['lutm', 'lutmi', 'lutmil', 'lutmila', 'lutrika', 'lutrik', 'lutri', 'lutr']
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kyanite/enumerable/enumerable_strings.rb', line 19 def palindrom_rumpf result = self.dup 0.upto( size/2 - 1 ) do |i| if result[0] == result[-1] result.delete_at(0) result.delete_at(-1) end end result end |