frabr_palindrome 0.1.0 → 0.2.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/frabr_palindrome.rb +16 -4
- data/lib/frabr_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: a945050cebfae5f245177d1168a5b149cbd397b1bef5a4da8084cb980d05df19
|
4
|
+
data.tar.gz: 979faf452f629578c4ceafd2f52a795f6c7064247587570fe5219d6f86261caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 324753c5ed56a04d9a0ef692ecb639e2d3d5a1ceefa07ea8c4adf77d08a8221b545e2acf6445df36fb6f38ca1a3c7bcbfbc26fc5cb4e29c9bee07dc29631508d
|
7
|
+
data.tar.gz: f6600897cf0b650325eef19395d2ab46432808651113358c5c9c392a58514f89a747ca730d9bd3ee2ba2e0e09afad494e2a87915b2a0a174c4a4424b720ea560
|
data/Gemfile.lock
CHANGED
data/lib/frabr_palindrome.rb
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
require "frabr_palindrome/version"
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
module FrabrPalindrome
|
4
5
|
|
5
6
|
# Returns true for a palindrome, false otherwise.
|
6
7
|
def palindrome?
|
7
|
-
|
8
|
+
if processed_content.empty?
|
9
|
+
false
|
10
|
+
else
|
11
|
+
processed_content == processed_content.reverse
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
|
-
|
11
15
|
private
|
12
16
|
|
13
17
|
# Returns content for palindrome testing.
|
14
18
|
def processed_content
|
15
|
-
self.scan(/[a-
|
19
|
+
self.to_s.scan(/[a-z0-9]/i).join.downcase
|
16
20
|
end
|
17
21
|
end
|
22
|
+
|
23
|
+
class String
|
24
|
+
include FrabrPalindrome
|
25
|
+
end
|
26
|
+
|
27
|
+
class Integer
|
28
|
+
include FrabrPalindrome
|
29
|
+
end
|