my_palindrome 0.2.0 → 0.2.1
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/README.md +51 -2
- data/lib/my_palindrome/version.rb +1 -1
- data/lib/my_palindrome.rb +9 -4
- 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: b8e444b24902e39a51120b4711d384905fa120a27b3ec369d09abede4eb916f3
|
4
|
+
data.tar.gz: 8ace69df0a4c29f43d43e64bafc29883185338924e157031309c26fa17db3a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 766486a3d132d7053c8c94e7c6f9b0abfae08a36886a5405d75a7d533d915b24b74b21c5cfd1aa79e01e7698d131617bb7952c9bdddce0e199fb0c20c23e2b21
|
7
|
+
data.tar.gz: 6dfa22ff8d1de996aa8575296858f7435bc281c89f72bb49b0bf9b72932a47c5b03866cc2ff3629f745968761786bfc760fa02933776d9180d19a13707687c79
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# MyPalindrome
|
1
|
+
<!-- # MyPalindrome
|
2
2
|
|
3
3
|
TODO: Delete this and the text below, and describe your gem
|
4
4
|
|
@@ -28,4 +28,53 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/my_palindrome.
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/my_palindrome. -->
|
32
|
+
|
33
|
+
|
34
|
+
# Palindrome detector
|
35
|
+
|
36
|
+
`my_palindrome` is a sample Ruby gem created in [*Learn Enough Ruby to Be Dangerous*](https://www.learnenough.com/ruby-tutorial) by Folahanmi Kolawole.
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
To install `my_palindrome`, add this line to your application's `Gemfile`:
|
41
|
+
|
42
|
+
```
|
43
|
+
gem 'my_palindrome'
|
44
|
+
```
|
45
|
+
|
46
|
+
Then install as follows:
|
47
|
+
|
48
|
+
```
|
49
|
+
$ bundle install
|
50
|
+
```
|
51
|
+
|
52
|
+
Or install it directly using `gem`:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ gem install mhartl_palindrome
|
56
|
+
```
|
57
|
+
|
58
|
+
## Usage
|
59
|
+
|
60
|
+
`my_palindrome` adds a `palindrome?` method to the `String` and `Integer` class, and can be used as follows:
|
61
|
+
|
62
|
+
```
|
63
|
+
$ irb
|
64
|
+
>> require 'my_palindrome'
|
65
|
+
>> "honey badger".palindrome?
|
66
|
+
=> false
|
67
|
+
>> "deified".palindrome?
|
68
|
+
=> true
|
69
|
+
>> "Able was I, ere I saw Elba.".palindrome?
|
70
|
+
=> true
|
71
|
+
>> phrase = "Madam, I'm Adam."
|
72
|
+
>> phrase.palindrome?
|
73
|
+
=> true
|
74
|
+
>> 12321.palindrome?
|
75
|
+
=> true
|
76
|
+
```
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/my_palindrome.rb
CHANGED
@@ -2,17 +2,22 @@
|
|
2
2
|
|
3
3
|
require_relative "my_palindrome/version"
|
4
4
|
|
5
|
+
# A module for palindrome testing.
|
5
6
|
module MyPalindrome
|
6
7
|
# Returns true for a palindrome, false otherwise.
|
7
8
|
def palindrome?
|
8
|
-
|
9
|
+
if processed_content.empty?
|
10
|
+
false
|
11
|
+
else
|
12
|
+
processed_content == processed_content.reverse
|
13
|
+
end
|
9
14
|
end
|
10
|
-
|
15
|
+
|
11
16
|
private
|
12
|
-
|
17
|
+
|
13
18
|
# Returns content for palindrome testing.
|
14
19
|
def processed_content
|
15
|
-
|
20
|
+
to_s.scan(/[a-z\d]/i).join.downcase
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_palindrome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Folahanmi Kolawole
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Learn Enough Ruby palindrome detector
|
14
14
|
email:
|