lib/kpietrzk_palindrome.rb in kpietrzk_palindrome-0.1.0 vs lib/kpietrzk_palindrome.rb in kpietrzk_palindrome-0.2.0
- old
+ new
@@ -1,24 +1,28 @@
# frozen_string_literal: true
require 'kpietrzk_palindrome/version'
-# Documentation comments
-class String
+
+module KpietrzkPalindrome
# Returns true for a palindrome, false otherwise.
def palindrome?
processed_content == processed_content.reverse
end
- # Returns the letters in the string.
- def letters
-
- end
-
private
# Returns content for palindrome testing.
def processed_content
- scan(/[a-z]/i).join('').downcase
+ to_s.scan(/[a-z\d]/i).join('').downcase
end
+end
+
+class String
+ include KpietrzkPalindrome
+
end
+
+class Integer
+ include KpietrzkPalindrome
+end
\ No newline at end of file