Sha256: a72ddc6221c80e2be36d215408af696f5af7c53507e00873ef50d9a60e98a940

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

require 'kpietrzk_palindrome/version'

module KpietrzkPalindrome
  # Returns true for a palindrome, false otherwise.
  def palindrome?
    processed_content == processed_content.reverse
  end

  private

  # Returns content for palindrome testing.
  def processed_content
    to_s.scan(/[a-z\d]/i).join('').downcase
  end

end


class String
  include KpietrzkPalindrome

end

class Integer
  include KpietrzkPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kpietrzk_palindrome-0.2.0 lib/kpietrzk_palindrome.rb