blazingwind_palindrome 0.1.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 +7 -0
- data/README.md +45 -0
- data/Rakefile +8 -0
- data/lib/blazingwind_palindrome/version.rb +5 -0
- data/lib/blazingwind_palindrome.rb +34 -0
- data/sig/blazingwind_palindrome.rbs +4 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '08005e144ebdaac6c85a2b94632a7d1f3bf724d7e805f9724e003edbbe045e01'
|
|
4
|
+
data.tar.gz: 7aa4b9efe6a371b2b6d57b166a48b165a0ce34b57ac66396e281ff9682c614ea
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d73b2074b43785dd8d9d1788bc519843ab9c41a29c08527b3affd34297ccb886b5e88d1b1d0b63925b5c0c989686ffcfbf344a312fb9a73c28f1f40eeee54190
|
|
7
|
+
data.tar.gz: f928c48ce595651b675457c19e460d48df2580ffb00148cd78474d89d1ba34c8522aab1cd40e10083e01630295b5b70e122ff45ca8a58c6da5c7079c0f0b6769
|
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Palindrome detector
|
|
2
|
+
|
|
3
|
+
`blazingwind_palindrome` is a sample Ruby gem created in [*Learn Enough Ruby to Be Dangerous*](https://www.learnenough.com/ruby-tutorial) by Michael Hartl.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install `blazingwind_palindrome`, add this line to your application's `Gemfile`:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem 'blazingwind_palindrome'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then install as follows:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install it directly using `gem`:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
$ gem install blazingwind_palindrome
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
`blazingwind_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
$ irb
|
|
31
|
+
>> require 'blazingwind_palindrome'
|
|
32
|
+
>> "honey badger".palindrome?
|
|
33
|
+
=> false
|
|
34
|
+
>> "deified".palindrome?
|
|
35
|
+
=> true
|
|
36
|
+
>> "Able was I, ere I saw Elba.".palindrome?
|
|
37
|
+
=> true
|
|
38
|
+
>> phrase = "Madam, I'm Adam."
|
|
39
|
+
>> phrase.palindrome?
|
|
40
|
+
=> true
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "blazingwind_palindrome/version"
|
|
4
|
+
|
|
5
|
+
class String
|
|
6
|
+
|
|
7
|
+
# Returns trye for a palidrome, false otherwise.
|
|
8
|
+
def palindrome?
|
|
9
|
+
processed_content == processed_content.reverse
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Returns the letters in the string. Used in processed_content
|
|
13
|
+
# def letters
|
|
14
|
+
# self.scan(/[a-zA-Z]*/).join
|
|
15
|
+
|
|
16
|
+
# the early version
|
|
17
|
+
# the_letters = []
|
|
18
|
+
# for i in 0..self.length - 1 do
|
|
19
|
+
# if self[i].match(/[a-zA-Z]/)
|
|
20
|
+
# the_letters << self[i]
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
# the_letters.join
|
|
24
|
+
|
|
25
|
+
# other option
|
|
26
|
+
# chars.select { |c| c.match(/[a-z]/i) }.join
|
|
27
|
+
# end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def processed_content
|
|
32
|
+
self.scan(/[a-zA-Z]*/).join.downcase
|
|
33
|
+
end
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: blazingwind_palindrome
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sylwia Budzynska
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Learn Enough Ruby palindrome detector
|
|
13
|
+
email:
|
|
14
|
+
- 102833689+sylwia-budzynska@users.noreply.github.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- Rakefile
|
|
21
|
+
- lib/blazingwind_palindrome.rb
|
|
22
|
+
- lib/blazingwind_palindrome/version.rb
|
|
23
|
+
- sig/blazingwind_palindrome.rbs
|
|
24
|
+
homepage: https://github.com/sylwia-budzynska/blazingwind_palindrome
|
|
25
|
+
licenses: []
|
|
26
|
+
metadata:
|
|
27
|
+
allowed_push_host: https://rubygems.org
|
|
28
|
+
homepage_uri: https://github.com/sylwia-budzynska/blazingwind_palindrome
|
|
29
|
+
source_code_uri: https://github.com/sylwia-budzynska/blazingwind_palindrome
|
|
30
|
+
changelog_uri: https://github.com/sylwia-budzynska/blazingwind_palindrome
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: 3.1.0
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 3.6.9
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: Palindrome detector
|
|
48
|
+
test_files: []
|