aga_palindrome 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aga_palindrome.rb +15 -3
- data/lib/aga_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: 3e12948f9c2cbdbc65e588fefa0ce7481c1cfd61a0579dc1e603640043bbd1b2
|
4
|
+
data.tar.gz: 4c9e743d73f0067b09f65dde2c5abca46770f20de2d29d0624bb1a00ae709295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7a7767ae1e5d3dcd56f036f8618a333786cefe32f0a3a800c223fe65f4ff68fcdd2209dfd917bf1b5d9d244463f8a836a3a7405087cecbc4b8dcbd0315b3e0
|
7
|
+
data.tar.gz: f0ef13266ab8bdd380ab12ba5abad36b6ff52f6fa912266dab58e51559c567476901c74e576c11e9a2ab6eea89b954d40dc0a965a3a45fe867f579c372375334
|
data/Gemfile.lock
CHANGED
data/lib/aga_palindrome.rb
CHANGED
@@ -1,16 +1,28 @@
|
|
1
1
|
require "aga_palindrome/version"
|
2
2
|
|
3
|
-
|
3
|
+
module AgaPalindrome
|
4
4
|
|
5
5
|
# Returns true for a palindrome, false otherwise.
|
6
6
|
def palindrome?
|
7
|
-
|
7
|
+
if processed_content.empty?
|
8
|
+
false
|
9
|
+
else
|
10
|
+
processed_content == processed_content.reverse
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
private
|
11
15
|
|
12
16
|
# Returns content for palindrome testing.
|
13
17
|
def processed_content
|
14
|
-
scan(/[a-z]/i).join.downcase
|
18
|
+
to_s.scan(/[][a-z]\d]/i).join.downcase
|
15
19
|
end
|
16
20
|
end
|
21
|
+
|
22
|
+
class String
|
23
|
+
include AgaPalindrome
|
24
|
+
end
|
25
|
+
|
26
|
+
class Integer
|
27
|
+
include AgaPalindrome
|
28
|
+
end
|