Sha256: 59ce756bdd6f5b70b66c3d3e931fc3c8fa15a8fd50d8dde79c1009fd19c1f1d2

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require "toninjaa_palindrome/version"

module ToninjaaPalindrome

  #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-z0-9]/i).join.downcase
    end
end

class String
  include ToninjaaPalindrome
end

class Integer
  include ToninjaaPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
toninjaa_palindrome-0.2.0 lib/toninjaa_palindrome.rb