hsztan_palindrome 0.2.1 → 0.5.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 +16 -0
- data/hsztan_palindrome.gemspec +2 -2
- data/lib/hsztan_palindrome/version.rb +1 -1
- data/lib/hsztan_palindrome.rb +11 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 693c708112c789cd7fe95543fa41ca1bdccf485a931873649f419dfa5ee5dd84
|
|
4
|
+
data.tar.gz: 17df511e0251c34d8d012b7335c53ef2a377c0be15e37f85a165a106d2f88f3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e20dcb96bc3eafd635c7d2b531c5eb521fb90a9bdb929e08bfe841db65c04909ed2556b1882b5449ec5118dfca0e6e9540386d55acac3cec06bd066f92c90c4
|
|
7
|
+
data.tar.gz: e207d5c83800bc626cd19d4f54360fa7805edba870f8831708fdd6a4effe7ecc218026672037badf173adad6a4fdeac4d901e206df13e0e84b2802ed3ac91bfb
|
data/README.md
CHANGED
|
@@ -38,6 +38,22 @@ require 'hsztan_palindrome'
|
|
|
38
38
|
|
|
39
39
|
12321.palindrome? # => true
|
|
40
40
|
|
|
41
|
+
[
|
|
42
|
+
[1, 2, 3],
|
|
43
|
+
[2, 3, 2],
|
|
44
|
+
[3, 2, 1]
|
|
45
|
+
].palindrome? # => true
|
|
46
|
+
|
|
47
|
+
[
|
|
48
|
+
[2, 3, 4],
|
|
49
|
+
[2, 3, 2],
|
|
50
|
+
[3, 2, 1]
|
|
51
|
+
].palindrome? # => false
|
|
52
|
+
|
|
53
|
+
[1, 2, 3, 4, 5].palindrome? # => false
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
41
57
|
```
|
|
42
58
|
|
|
43
59
|
## Development
|
data/hsztan_palindrome.gemspec
CHANGED
|
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.authors = ["Henry Nawrocki"]
|
|
7
7
|
spec.email = ["henry@sztanski.com"]
|
|
8
8
|
|
|
9
|
-
spec.summary = %q{Palindrome detector
|
|
10
|
-
spec.description = %q{
|
|
9
|
+
spec.summary = %q{Palindrome detector}
|
|
10
|
+
spec.description = %q{Palindrome detector for strings, integers, and arrays.}
|
|
11
11
|
spec.homepage = "https://github.com/hsztan/hsztan_palindrome"
|
|
12
12
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
13
13
|
|
data/lib/hsztan_palindrome.rb
CHANGED
|
@@ -3,12 +3,18 @@ require "hsztan_palindrome/version"
|
|
|
3
3
|
module HsztanPalindrome
|
|
4
4
|
|
|
5
5
|
def palindrome?
|
|
6
|
-
|
|
6
|
+
return false if processed_content.empty?
|
|
7
|
+
return true if processed_content.length == 1
|
|
8
|
+
check_for_palindrome
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
private
|
|
12
|
+
def check_for_palindrome
|
|
13
|
+
processed_content == processed_content.reverse
|
|
14
|
+
end
|
|
10
15
|
|
|
11
16
|
def processed_content
|
|
17
|
+
self.flatten if self.is_a?(Array)
|
|
12
18
|
self.to_s.scan(/[a-z\d]/i).join.downcase
|
|
13
19
|
end
|
|
14
20
|
end
|
|
@@ -19,4 +25,8 @@ end
|
|
|
19
25
|
|
|
20
26
|
class Integer
|
|
21
27
|
include HsztanPalindrome
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Array
|
|
31
|
+
include HsztanPalindrome
|
|
22
32
|
end
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hsztan_palindrome
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henry Nawrocki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-01-
|
|
11
|
+
date: 2023-01-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: Palindrome detector for strings, integers, and arrays.
|
|
14
14
|
email:
|
|
15
15
|
- henry@sztanski.com
|
|
16
16
|
executables: []
|
|
@@ -53,5 +53,5 @@ requirements: []
|
|
|
53
53
|
rubygems_version: 3.1.6
|
|
54
54
|
signing_key:
|
|
55
55
|
specification_version: 4
|
|
56
|
-
summary: Palindrome detector
|
|
56
|
+
summary: Palindrome detector
|
|
57
57
|
test_files: []
|