module NymousPalindrome

Constants

VERSION

Public Instance Methods

palindrome?() click to toggle source

Test if a String is a palindrome (ie it reads the same from left to right and from right to left) @example

"not a palindrome".palindrome? #=> false
"Racecar".palindrome? #=> true

@return [Boolean]

# File lib/nymous_palindrome.rb, line 9
def palindrome?
  return false if processed_content.empty?

  processed_content == processed_content.reverse
end

Private Instance Methods

processed_content() click to toggle source
# File lib/nymous_palindrome.rb, line 17
def processed_content
  self.to_s.scan(/[[:alnum:]]/i).join.downcase
end