Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/palindrome_ext/string.rb
Overview
Overrides Default String Class by adding #palindrome? method
Instance Method Summary collapse
-
#palindrome?(strict = true) ⇒ Boolean
Whether or not the string is a palindrome.
Instance Method Details
#palindrome?(strict = true) ⇒ Boolean
Returns Whether or not the string is a palindrome.
8 9 10 11 12 |
# File 'lib/palindrome_ext/string.rb', line 8 def palindrome?(strict = true) str = self str = str.downcase.tr("^a-z0-9", "") unless strict str == str.reverse end |