Sha256: 18ffc270da69ec90a686cb129b30005f01c2532954f5a14c1abe8cb5d5e6a5c1

Contents?: true

Size: 465 Bytes

Versions: 1

Compression:

Stored size: 465 Bytes

Contents

require "hkn_palindrome/version"

module HknPalindrome

  #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 HknPalindrome
end

class Integer
  include HknPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hkn_palindrome-0.1.1 lib/hkn_palindrome.rb