mikef_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/README.md +5 -7
- data/lib/mikef_palindrome/version.rb +1 -1
- data/lib/mikef_palindrome.rb +10 -2
- 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: 9c5585d0640302a756db4341a9d808ed2461efd7dfa2f5e4446dd078b568301b
|
4
|
+
data.tar.gz: df8283a6354fa01cd364658f1e5bb3f5119243c2bb8e0944c0a3be78b5b0dbc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853d126a0fe795b53d99d68aea964d4ace311c7f76f8287a811494b8701d600540ac77ff3e4b92bd6321258073cd2e75fd984192ccb8a5d3d45d8a479013cf51
|
7
|
+
data.tar.gz: 5b32fc2ea1d00f572abd724a9aac05c62f1ac2de07a4963f03306bc257356afefee25b8d137130af459158f767d63a61f4b21aaccc52055e6d5142f069c19341
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MikefPalindrome
|
2
2
|
|
3
|
-
Checks whether a `String` is a palindrome or not.
|
3
|
+
Checks whether a `String` or `Integer` is a palindrome or not.
|
4
4
|
Returns a boolean.
|
5
5
|
|
6
6
|
## Installation
|
@@ -29,14 +29,12 @@ Or install it yourself as:
|
|
29
29
|
"This isn't a palindrome".palindrome?
|
30
30
|
>> false
|
31
31
|
|
32
|
-
|
33
|
-
p.palindrome?
|
34
|
-
>> true
|
35
|
-
|
36
|
-
np = "This isn't a palindrome"
|
37
|
-
np.palindrome?
|
32
|
+
12345.palindrome?
|
38
33
|
>> false
|
39
34
|
|
35
|
+
12321.palindrome?
|
36
|
+
>> true
|
37
|
+
|
40
38
|
## Development
|
41
39
|
|
42
40
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/mikef_palindrome.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'mikef_palindrome/version'
|
2
2
|
|
3
|
-
|
3
|
+
module MikefPalindrome
|
4
4
|
# returns true for a palindrome, false otherwise
|
5
5
|
def palindrome?
|
6
6
|
processed_content == processed_content.reverse
|
@@ -10,6 +10,14 @@ class String
|
|
10
10
|
|
11
11
|
# returns content for palindrome testing
|
12
12
|
def processed_content
|
13
|
-
scan(/[a-z]/i).join.downcase
|
13
|
+
to_s.scan(/[a-z\d]/i).join.downcase
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
class String
|
18
|
+
include MikefPalindrome
|
19
|
+
end
|
20
|
+
|
21
|
+
class Integer
|
22
|
+
include MikefPalindrome
|
23
|
+
end
|