Sha256: 7a7793116c2e5a77795b38c262f1fa857e7f5264f01004aee502264eb2d49f75

Contents?: true

Size: 511 Bytes

Versions: 1

Compression:

Stored size: 511 Bytes

Contents

require "HumbleCarrot_palindrome/version"

module HumbleCarrotPalindrome

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

class String
  include HumbleCarrotPalindrome
end

class Integer
  include HumbleCarrotPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
HumbleCarrot_palindrome-0.1.1 lib/HumbleCarrot_palindrome.rb