Sha256: 506b89e136feb82b7829e7c104c6d21466f3b57d0863c106d98a18260168c462

Contents?: true

Size: 496 Bytes

Versions: 1

Compression:

Stored size: 496 Bytes

Contents

require "juandpineiro_palindrome/version"

module JuandpineiroPalindrome
  # Returns true for a palindrome, false otherwise.
  def palindrome?
    if processed_content.empty?
      false
    else
      processed_content == processed_content.reverse
    end
  end

  private

  # Returns content for palindrome testing.
  def processed_content
    to_s.scan(/[a-z\d]/i).join.downcase
  end
end

class String
  include JuandpineiroPalindrome
end

class Integer
  include JuandpineiroPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
juandpineiro_palindrome-0.2.0 lib/juandpineiro_palindrome.rb