bt_palindrome 0.1.0 → 0.2.0
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/bt_palindrome/version.rb +1 -1
- data/lib/bt_palindrome.rb +13 -3
- 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: 27b03848dfa29b1292473d0da5219adc239b6d560bce5631ba9511b4ee12a5b2
|
4
|
+
data.tar.gz: b99732faba7687d7e9e0a05f5f64d104e6f509ed6a0fe0dac53e6f1767569232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b8427b15d0023b5b427ed7c8f8438950483ae32d072091bdfb90325ab85584767a7e2e5bee378262e05dab94ab7b6b94d4fb52c1dbd8a6a4f1dd96867f398cd
|
7
|
+
data.tar.gz: 403af6a74d0b89aebe2d6f423913c572752877c175f0dff80db964b5e4fe1ba17b7b30b85da743913a88316d15adf5682c968d2da4873ea22898ba4408645c57
|
data/Gemfile.lock
CHANGED
data/lib/bt_palindrome.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative "bt_palindrome/version"
|
4
4
|
|
5
|
-
#
|
6
|
-
|
5
|
+
# Contains functionality to detect palindromes
|
6
|
+
module Palindrome
|
7
7
|
def palindrome?
|
8
8
|
processed_string == processed_string.reverse
|
9
9
|
end
|
@@ -11,6 +11,16 @@ class String
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def processed_string
|
14
|
-
downcase.split(/\W/).join
|
14
|
+
to_s.downcase.split(/\W/).join
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
# Extend String to have a palindrome function
|
19
|
+
class String
|
20
|
+
include Palindrome
|
21
|
+
end
|
22
|
+
|
23
|
+
# Extend Integer to have a palindrome function
|
24
|
+
class Integer
|
25
|
+
include Palindrome
|
26
|
+
end
|