agustin_palindrome 0.1.0 → 0.3.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 -1
- data/lib/agustin_palindrome/version.rb +1 -1
- data/lib/agustin_palindrome.rb +12 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eff0bcb4b678ccb4df670b4130b695be5cc5a8a3cf5ca3ba235b8767d1276620
|
4
|
+
data.tar.gz: 072e65470d6a9abe19f9d6e9128b26baccd10cf30641d11bc4447d95e35536fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fab0fecd013faf532447b69c5ddff7bcd3560895a1b452b3f9d4b8f3fc546619555977dd00c285e0b199f763adea741ce33db85d95c07647ac19316dab5ef9e0
|
7
|
+
data.tar.gz: 36b8749287784d2bc26988564e8e1645fd944c577c7df863709e1eb47e1c4d54d5cceffb964c0d6e3af9c244cbf663f04fd228b45b48837350a9491bf771e221
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ $ gem install agustin_palindrome
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
`agustin_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
|
27
|
+
`agustin_palindrome` adds a `palindrome?` method to the `String` and to the `Integer` class, and can be used as follows:
|
28
28
|
|
29
29
|
```
|
30
30
|
$ irb
|
@@ -38,6 +38,10 @@ $ irb
|
|
38
38
|
>> phrase = "Madam, I'm Adam."
|
39
39
|
>> phrase.palindrome?
|
40
40
|
=> true
|
41
|
+
>> 12345.palindrome?
|
42
|
+
=> false
|
43
|
+
>> 1234321.palindrome?
|
44
|
+
=> true
|
41
45
|
```
|
42
46
|
|
43
47
|
## License
|
data/lib/agustin_palindrome.rb
CHANGED
@@ -2,18 +2,24 @@
|
|
2
2
|
|
3
3
|
require_relative "agustin_palindrome/version"
|
4
4
|
|
5
|
-
|
5
|
+
module AgustinPalindrome
|
6
6
|
def palindrome?
|
7
|
+
return false if processed_content.empty?
|
8
|
+
|
7
9
|
processed_content == processed_content.reverse
|
8
10
|
end
|
9
11
|
|
10
|
-
def letters
|
11
|
-
scan(/[a-z]/i).join
|
12
|
-
end
|
13
|
-
|
14
12
|
private
|
15
13
|
|
16
14
|
def processed_content
|
17
|
-
|
15
|
+
to_s.scan(/[a-z\d]/i).join.downcase
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
19
|
+
class String
|
20
|
+
include AgustinPalindrome
|
21
|
+
end
|
22
|
+
|
23
|
+
class Integer
|
24
|
+
include AgustinPalindrome
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agustin_palindrome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AgustinPalmaM
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|