Sha256: 6bb4ed70a6443a2da7a2321cac1558e43d37f91ef49203ad08233819985df545

Contents?: true

Size: 399 Bytes

Versions: 1

Compression:

Stored size: 399 Bytes

Contents

require "palindrome_detector/version"

module Palindrome
  # Returns true for a palindrome, false otherwise.
  def palindrome?
    processed_content == processed_content.reverse
  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 Palindrome
end


class Integer
  include Palindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
palindrome_detector-0.2.0 lib/palindrome_detector.rb