Sha256: a93a37527738d5f0b73c2cdd787a95ce9c6cf91ca0cf54833d91b05d6e37dabe

Contents?: true

Size: 490 Bytes

Versions: 2

Compression:

Stored size: 490 Bytes

Contents

require "cspeezy_palindrome/version"

module CspeezyPalindrome

  # 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
      self.to_s.scan(/[a-z\d]/i).join.downcase
    end
end

class String
  include CspeezyPalindrome
end

class Integer
  include CspeezyPalindrome
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cspeezy_palindrome-0.3.0 lib/cspeezy_palindrome.rb
cspeezy_palindrome-0.2.0 lib/cspeezy_palindrome.rb