hsztan_palindrome 0.2.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ee1be11d919b7005f33b7a1a0ef105a45f31756160d7fbe29b6a5eedc9c28c
4
- data.tar.gz: 42b9f5549c53712f9639559baa75643ee66942d85c9c44b2cb1b8b0da9092369
3
+ metadata.gz: '049b280227fde13985fe58e32a4847b4ca30e77992f14cce7832335ad9ee5ec8'
4
+ data.tar.gz: cc383beece4804027d42e990c1e8e9394916b112a155d21c008bc5df65eff14f
5
5
  SHA512:
6
- metadata.gz: b40f145cb5a12620fac613cd18fdb54bbfd0eeb8ac94ac11367359d77b6850bf46d6f8645a7ef6d62f8c03355a46980b6e311fd68eb5d9ae785a862ef15e1b4e
7
- data.tar.gz: 14d0fdd633a6d8ccde775b52d3fd3f2958e8a7292a4604ff3b03955698652ba029ad78ae51382f77166ffeabaa68776c409fa6703b5e567640807df89585e653
6
+ metadata.gz: b813720a0f610c404e5f5e9bbe9c1c3c14e637eb59832c6c5cc4bad331329dd6241c5fa4f31f6364e7ab65e9f60182f1331423743e78e05df718e3151ca34a9e
7
+ data.tar.gz: 412d1d195521c010861c23dcd462ae87838d7b5c4b13a407f8c18a83395452839d065cd6c85066c651a897c7e2e88098bc16446e13d447ef58a666ffecebdb1f
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # HsztanPalindrome
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hsztan_palindrome`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- This gem is a palindrome detector for strings. It can be used as a library or as a command line tool.
5
+ This gem is a palindrome detector for strings and integers. It can be used as a library or as a command line tool.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,9 +22,23 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Use as a library:
25
+ Use as a library:
26
26
 
27
- ```ruby
27
+ ```
28
+
29
+ require 'hsztan_palindrome'
30
+ ```
31
+
32
+ ```
33
+ "foo".palindrome? # => false
34
+
35
+ "racecar".palindrome? # => true
36
+
37
+ 12345.palindrome? # => false
38
+
39
+ 12321.palindrome? # => true
40
+
41
+ ```
28
42
 
29
43
  ## Development
30
44
 
@@ -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{Learn Enough Ruby palindrome detector.}
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
 
@@ -1,3 +1,3 @@
1
1
  module HsztanPalindrome
2
- VERSION = "0.2.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -3,12 +3,18 @@ require "hsztan_palindrome/version"
3
3
  module HsztanPalindrome
4
4
 
5
5
  def palindrome?
6
- processed_content == processed_content.reverse
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.2.0
4
+ version: 0.5.0
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-06 00:00:00.000000000 Z
11
+ date: 2023-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Learn Enough Ruby palindrome detector.
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: []