Skip to content

aj-rom/palindrome_ext

Repository files navigation

PalindromeExt

Ruby Gem Version Downloads Ruby Style Guide Platform

A gem focused on extending Ruby's String and Integer classes by adding a .palindrome? method, to solve a common algorithm problem of determining whether a string or integer may be a palindrome.

Installation

Add this line to your application's Gemfile:

gem 'palindrome_ext'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install palindrome_ext

Usage

Detailed documentation can be found at https://rubydoc.info/gems/palindrome_ext.

String

require 'palindrome_ext/string'

# Palindrome - Case Sensitive & Whitespace Sensitive
'Example...'.palindrome? # => false
'radar'.palindrome? # => true
'Radar'.palindrome? # => false

# Non-Strict Palindrome - Removes whitespace, punctuation, and capitalization before checking.
'Radar'.palindrome? false # => true
'RadaR'.palindrome? # => false

Integer

require 'palindrome_ext/integer'

# Palindrome - Check if the integer is a palindrome
112.palindrome? # => false
101.palindrome? # => true

# And works on operations
(91 * 99).palindrome? # => true

Development

Dependency Management

After forking this repo, navigate to the root directory and run:

$ bundle install

Testing with RSpec

To run tests, simply run:

$ rake test

Linting with RuboCop

To check if there are any style offenses in your forked repository and automatically fix these offenses, run:

$ rake lint

Benchmarking

To execute a benchmark report, run:

$ rake benchmark

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/aj-rom/palindrome_ext. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the PalindromeExt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

A simple gem that extends the String, Integer, and Array classes of Ruby, by adding a 'palindrome?' method.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks