Sha256: b18765182debe439e9cd6cedc4a91bd79ab073e47ee88597f8b69ac126407d7e

Contents?: true

Size: 465 Bytes

Versions: 1

Compression:

Stored size: 465 Bytes

Contents

# frozen_string_literal: true

require_relative "dgamboa_palindrome/version"

module DgamboaPalindrome
  # 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-z\d]/i).join.downcase
    end
end

class String
  include DgamboaPalindrome
end

class Integer
  include DgamboaPalindrome
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dgamboa_palindrome-0.2.0 lib/dgamboa_palindrome.rb