Module: PatrickPalindrome

Included in:
Integer, String
Defined in:
lib/patrick_palindrome.rb,
lib/patrick_palindrome/version.rb

Constant Summary collapse

VERSION =
"0.3.0"

Instance Method Summary collapse

Instance Method Details

#palindrome?Boolean

Returns true for a palindrome, false otherwise.

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/patrick_palindrome.rb', line 8

def palindrome?

  # Empty strings are not palindromes
  if processed_content.length == 0
    return false
  end

  # Strings with only whitespace characters are not palindromes
  if processed_content.scan(/\S/).length == 0
    return false
  end

  processed_content == processed_content.reverse
end