andjela_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/CHANGELOG.md +5 -0
- data/README.md +45 -0
- data/Rakefile +12 -0
- data/lib/andjela_palindrome/version.rb +5 -0
- data/lib/andjela_palindrome.rb +24 -0
- data/sig/andjela_palindrome.rbs +4 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2962916d3103e743f1b0eb35479dbd3eee7119a1baf3313314177392ce644506
|
|
4
|
+
data.tar.gz: 339216c00610adee17858b3bb28cf21bb650c530b7083c57bb9e6ad6bb190bcf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ab713158bf6d34c529a8645d9240a18c393d352235ec7b6beacb12be89dfd71c562dd95e252bed230b6e45893d8b34492a934bfd4774617f0c9124df94bd682a
|
|
7
|
+
data.tar.gz: de1e7803430f183c0add8d1d64d96a9f0c8eca5d9e2363b4596627b7e55589c7d29e46b1cd85396a05451c9e123378aa35626572596ed3442ca9eca0a406c7fc
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Palindrome detector
|
|
2
|
+
|
|
3
|
+
`andjela_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 `andjela_palindrome`, add this line to your application's `Gemfile`:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem 'andjela_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 andjela_palindrome
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
`andjela_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
$ irb
|
|
31
|
+
>> require 'andjela_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,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "andjela_palindrome/version"
|
|
4
|
+
|
|
5
|
+
class String
|
|
6
|
+
|
|
7
|
+
# Returns true for a palindrome, false otherwide.
|
|
8
|
+
def palindrome?
|
|
9
|
+
processed_content == processed_content.reverse
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Returns the letters in the string
|
|
13
|
+
def letters
|
|
14
|
+
self.chars.select { |c| c.match(/[a-z]/i) }.join
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# Returns content for palindrome testing
|
|
21
|
+
def processed_content
|
|
22
|
+
scan(/[a-z]/i).join.downcase
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: andjela_palindrome
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Anđela
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: "%q{Learn Enough Ruby palindrome detector}."
|
|
13
|
+
email:
|
|
14
|
+
- andjela.jovicic0@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- CHANGELOG.md
|
|
20
|
+
- README.md
|
|
21
|
+
- Rakefile
|
|
22
|
+
- lib/andjela_palindrome.rb
|
|
23
|
+
- lib/andjela_palindrome/version.rb
|
|
24
|
+
- sig/andjela_palindrome.rbs
|
|
25
|
+
homepage: https://github.com/andjxla/andjela_palindrome
|
|
26
|
+
licenses: []
|
|
27
|
+
metadata:
|
|
28
|
+
allowed_push_host: https://rubygems.org/
|
|
29
|
+
homepage_uri: https://github.com/andjxla/andjela_palindrome
|
|
30
|
+
source_code_uri: https://github.com/andjxla/andjela_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.2.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: 4.0.16
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: "%q{Palindrome detector}"
|
|
48
|
+
test_files: []
|