Sha256: c8f2a425ac52d1acad106697e47c551c2e6330b955531bc01bb56d694a4eaa4c

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

require "davejskim_palindrome/version"

module DavejskimPalindrome
  def palindrome?
    processed_content == processed_content.reverse    
  end
  
  private
    def processed_content
      self.to_s.scan(/[a-z\d]/i).join.downcase
    end
end

class String
  include DavejskimPalindrome
end

class Integer
  include DavejskimPalindrome
end

  
  # def letters
  #   the_letters=[]
  #   letter_regex = /[a-z]/i
  #   self.chars.each do |character|
  #     if character.match(letter_regex)
  #       the_letters << character
  #     end
  #   end
  #   the_letters.join
  # end
  
  # def letters
  #   self.chars.select { |c| c.match(/[a-z]/i) }.join
  # end

  # private
  #   def processed_content
  #     self.letters.downcase
  #   end



Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
davejskim_palindrome-0.2.0 lib/davejskim_palindrome.rb