poppacalypse_palindrome 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 528818ebd04643748a2e331ed4c1fc67ecdd5429b6573e5ea00f241c8fb984fd
4
- data.tar.gz: a6ad400754d7aa28aff3eb5fcada90733a5dc1f4fdeb0ab3099fc3275d9c3041
3
+ metadata.gz: badaccfc9cedab29e3e4ad843057ef365f8498e346be948c336d8b3b55060140
4
+ data.tar.gz: efaac2c037c783461a4d47f8b03468dbaa077638d21cf4a28bbd5625cd3fb7db
5
5
  SHA512:
6
- metadata.gz: 0f218f34700e4366e93e97bd9afda33589f8659067dbfef4e9c50ada1a9508a6e20c88a3fd4aaf8526bc7d6a4e03babf2429d66e6e58351602fce1f24e10db2a
7
- data.tar.gz: 4b082ad1bb539bc1ffe9d118256263f9e52d0cee2f78169d660855ce5491a8742ac8ccf924f509a555f3be2b3cbd250c4e9f420826374ba0e217e013cea620f1
6
+ metadata.gz: 59f752adbff123af7097b31b21aace89e638226f55ed63b77bb16c80463b18930842a008cb889eecb1ccbcb00a9bbadecf9d1c93462843e269e14620bf84c964
7
+ data.tar.gz: 5541715856f757f4d7a2bd79bd45cb1e01607f0e711ff9c1b78133073203e39da74a8dae6339da5d8941d4e2f7d85c66c0b0f70028e5e524bcd4a50e46205e24
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- poppacalypse_palindrome (0.1.1)
4
+ poppacalypse_palindrome (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,59 +1,90 @@
1
1
  require "poppacalypse_palindrome/version"
2
2
 
3
- class String
3
+ # =============== Ch 8.5 Refactor: Exercise ===================
4
+ # =============== Restore the module ===============
5
+
6
+ module PoppacalypsePalindrome
4
7
 
5
- # Returns true for a palindrome, false otherwise
6
- def palindrome?
7
- processed_content == processed_content.reverse
8
- end
9
-
10
- # ========== Testing & TDD =======================
11
- # =============== Ch 8.4 Green ===================
12
-
13
- # Returns only the letters in the string
14
- # def letters
15
- # the_letters = []
16
- # for i in 0..self.length - 1 do
17
- # if self[i].match(/[a-zA-z]/)
18
- # the_letters << self[i]
19
- # end
20
- # end
21
- # the_letters.join
22
- # end
23
-
24
- # =============== Ch 8.5 Refactor: Method 1 ===================
25
-
26
- # def letters
27
- # the_letters = []
28
- # letter_regex = /[a-z]/i
29
- # self.chars.each do |character|
30
- # if character.match(letter_regex)
31
- # the_letters << character
32
- # end
33
- # end
34
- # the_letters.join
35
- # end
36
-
37
- # =============== Ch 8.5 Refactor: Method 2 ===================
38
-
39
- # def letters
40
- # # self.chars.select { |c| c.match(/[a-z]/i) }.join
41
- # chars.select { |c| c.match(/[a-z]/i) }.join
42
- # end
43
-
44
- private
45
-
46
- # ============ Ch 8.5 Refactor: Method 3 ==================
47
- # It's so compact that we can put it directly in processed_content, instead of defining a method of its own as the above 2 examples.
48
- # We also won't be needing test_letters in the test file
49
-
50
- # Returns content for palindrome testing
51
- # def processed_content
52
- # self.letters.downcase
53
- # end
54
-
55
- def processed_content
56
- self.scan(/[a-z]/i).join.downcase
8
+ # Returns true for palindrome, false otherwise
9
+ def palindrome?
10
+ processed_content == processed_content.reverse
57
11
  end
58
12
 
13
+ private
14
+
15
+ # Returns content for palindrome testing
16
+ def processed_content
17
+ # self.to_s.scan(/[a-z]/i).join.downcase
18
+
19
+ # include digits to accomodate integers
20
+ self.to_s.scan(/[a-z\d]/i).join.downcase
21
+ end
59
22
  end
23
+
24
+ class String
25
+ include PoppacalypsePalindrome
26
+ end
27
+
28
+ class Integer
29
+ include PoppacalypsePalindrome
30
+ end
31
+
32
+ # -------------------------------------------
33
+
34
+ # class String
35
+ #
36
+ # # Returns true for a palindrome, false otherwise
37
+ # def palindrome?
38
+ # processed_content == processed_content.reverse
39
+ # end
40
+ #
41
+ # # ========== Testing & TDD =======================
42
+ # # =============== Ch 8.4 Green ===================
43
+ #
44
+ # # Returns only the letters in the string
45
+ # # def letters
46
+ # # the_letters = []
47
+ # # for i in 0..self.length - 1 do
48
+ # # if self[i].match(/[a-zA-z]/)
49
+ # # the_letters << self[i]
50
+ # # end
51
+ # # end
52
+ # # the_letters.join
53
+ # # end
54
+ #
55
+ # # =============== Ch 8.5 Refactor: Method 1 ===================
56
+ #
57
+ # # def letters
58
+ # # the_letters = []
59
+ # # letter_regex = /[a-z]/i
60
+ # # self.chars.each do |character|
61
+ # # if character.match(letter_regex)
62
+ # # the_letters << character
63
+ # # end
64
+ # # end
65
+ # # the_letters.join
66
+ # # end
67
+ #
68
+ # # =============== Ch 8.5 Refactor: Method 2 ===================
69
+ #
70
+ # # def letters
71
+ # # # self.chars.select { |c| c.match(/[a-z]/i) }.join
72
+ # # chars.select { |c| c.match(/[a-z]/i) }.join
73
+ # # end
74
+ #
75
+ # private
76
+ #
77
+ # # ============ Ch 8.5 Refactor: Method 3 ==================
78
+ # # It's so compact that we can put it directly in processed_content, instead of defining a method of its own as the above 2 examples.
79
+ # # We also won't be needing test_letters in the test file
80
+ #
81
+ # # Returns content for palindrome testing
82
+ # # def processed_content
83
+ # # self.letters.downcase
84
+ # # end
85
+ #
86
+ # def processed_content
87
+ # self.scan(/[a-z]/i).join.downcase
88
+ # end
89
+ #
90
+ # end
@@ -1,3 +1,3 @@
1
1
  module PoppacalypsePalindrome
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poppacalypse_palindrome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Poppa