mhartl_palindrome 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6229122ab701751065e2ab7f56a92474ac278c0657a66f85b8dfb4a5f3828fd
4
- data.tar.gz: aa8083d979fd57338d1ab8101e3fae87401acedc4c123f3c86e5af871e6bf4de
3
+ metadata.gz: 81cdc690fc626f2a67ab34e1f5bd51d3cb7bc4da44da5c7b7d3337ee0bf2cfca
4
+ data.tar.gz: 9a97d7bc16ab6faea5703de2c113d8980305e79146d479b71cb79dcb32140f7a
5
5
  SHA512:
6
- metadata.gz: 9a4a5f4e42ab66f2c83648a4f2513674c3aa4f2da36ce98818f3eda116b68d36faccdd33726b4a201180a33e697b6420429d7200952c90aa1a92267adfd7ac7d
7
- data.tar.gz: d929fa045df920c99bad8a41e0da8ebe249f8994bb390fce49913302d1216c282b6a39432fe433d650d9a07995d189481f12184249b1519c06506f0f82bdf4cf
6
+ metadata.gz: eafea7c4fb6102d3407d2dc5d8ec3ab0cc15b157827205fc3538a666824bc0139c6f7981b5461e9250a580367eb2c937975d90e1cc00ece91ceb0d256b368454
7
+ data.tar.gz: e951fd4e19a1a160e7f5c740c90aa3b974bc349cf790af9f4cff2bf5d0255b4f85c9142b419335bb658b3726524e2e7a7c77e22965985a6241ab627c4581084c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mhartl_palindrome (0.1.0)
4
+ mhartl_palindrome (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -28,4 +28,4 @@ DEPENDENCIES
28
28
  rake (~> 10.0)
29
29
 
30
30
  BUNDLED WITH
31
- 1.16.2
31
+ 1.16.3
data/README.md CHANGED
@@ -1,38 +1,44 @@
1
- # MhartlPalindrome
1
+ # Palindrome detector
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/mhartl_palindrome`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ `mhartl_palindrome` is a sample Ruby gem created in [*Learn Enough Ruby to Be Dangerous*](https://www.learnenough.com/ruby-tutorial) by Michael Hartl.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
7
+ To install `mhartl_palindrome`, add this line to your application's `Gemfile`:
10
8
 
11
- ```ruby
9
+ ```
12
10
  gem 'mhartl_palindrome'
13
11
  ```
14
12
 
15
- And then execute:
13
+ Then install as follows:
16
14
 
17
- $ bundle
15
+ ```
16
+ $ bundle install
17
+ ```
18
18
 
19
- Or install it yourself as:
19
+ Or install it directly using `gem`:
20
20
 
21
- $ gem install mhartl_palindrome
21
+ ```
22
+ $ gem install mhartl_palindrome
23
+ ```
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ `mhartl_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
26
28
 
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mhartl_palindrome.
29
+ ```
30
+ $ irb
31
+ >> require 'mhartl_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
+ ```
36
42
 
37
43
  ## License
38
44
 
@@ -1,3 +1,3 @@
1
1
  module MhartlPalindrome
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -2,13 +2,19 @@ require "mhartl_palindrome/version"
2
2
 
3
3
  class String
4
4
 
5
- # Processes content for palindrome testing.
6
- def processed_content
7
- self.scan(/[a-z]/i).join.downcase
8
- end
9
-
10
5
  # Returns true for a palindrome, false otherwise.
11
6
  def palindrome?
12
- processed_content == processed_content.reverse
7
+ if processed_content.empty?
8
+ false
9
+ else
10
+ processed_content == processed_content.reverse
11
+ end
13
12
  end
13
+
14
+ private
15
+
16
+ # Returns content for palindrome testing.
17
+ def processed_content
18
+ self.scan(/[a-z]/i).join.downcase
19
+ end
14
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mhartl_palindrome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler