JohnnyNumber5_palindrome 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/JohnnyNumber5_palindrome.rb +16 -12
- data/lib/JohnnyNumber5_palindrome/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8235abd62945d424e51663da1915f35c0fd8426fc004d7b2a1616dbac0ed1231
|
4
|
+
data.tar.gz: d29aa73fa396b240247c0f4f0ea22fc4f66f917960080ddc5bb493ffc62edfe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9668ead149614aa3bd002c7ff1ae58fe10074ee48980805cd433d9442f75e7a7cb562ea3c1129d6585968ed8d9560ff35e256d57c5647387e54a7e1ae949dd1
|
7
|
+
data.tar.gz: '03621986fb7c7c9eced5a46d5bf71b86c8f7aeab0294f6217ed4f1fe50b94a5f02bfc62b1d8967f84fb6a09414dad1a5f981d062d03e679c308a3ee60370a177'
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
require "JohnnyNumber5_palindrome/version"
|
2
2
|
|
3
|
-
|
3
|
+
module JohnnyNumber5Palindrome
|
4
|
+
class Error < StandardError; end
|
4
5
|
|
5
|
-
# Returns true
|
6
|
+
# Returns true if the text is a palindrome, false otherwise.
|
6
7
|
def palindrome?
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
self.chars.select { |c| c.match(/[a-z]/i) }.join
|
8
|
+
if processed_content.empty?
|
9
|
+
false
|
10
|
+
else
|
11
|
+
processed_content == processed_content.reverse
|
12
|
+
end
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# Converts the string's content to lower case.
|
18
|
+
def processed_content
|
19
|
+
scan(/[a-z]/i).join.downcase
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class String
|
24
|
+
include JohnnyNumber5Palindrome
|
21
25
|
end
|