Sha256: 2d19ef4bd665ac34024a075302e4f5d5392ad9dac1aa529a1e918347d6649fc6

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

require "lgrgic_palindrome_detector/version"

module MhartlPalindrome

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

class Integer
  include MhartlPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lgrgic_palindrome_detector-0.2.0 lib/lgrgic_palindrome_detector.rb