Module: OpenString
- Included in:
- String
- Defined in:
- lib/open_string.rb
Overview
Public: Provides extension methods for the built-in String class.
Defined Under Namespace
Modules: CharacterSets, ClassMethods
Instance Method Summary collapse
-
#palindrome? ⇒ Boolean
Public: Determines if self has the same sequence of characters as evaluated from index 0 to self.length and from self.length to 0.
Instance Method Details
#palindrome? ⇒ Boolean
Public: Determines if self has the same sequence of characters as evaluated from index 0 to self.length and from self.length to 0. This ignores whitespace and casing.
Returns true iff self contains the same sequence of characters forwards as it does backwards.
11 12 13 |
# File 'lib/open_string.rb', line 11 def palindrome? gsub(/\s+/, '').casecmp(reverse.gsub(/\s+/, '')) == 0 end |