Sha256: b72617e6215d95a5e2e5bc5b364b9862cf4f7e4f55dc0555f72f806047c66ab1

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

require "snajam_palindrome/version"
#module SnajamPalindrome

class String

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

  # Returns the letters in the string.
  # def letters
   #self.chars.select { |c| c.match(/[a-z]/i) }.join
  #end

  private

  # Returns content for palindrome testing.
  def processed_content
    self.scan(/[a-z]/i).join.downcase
    #self.letters.downcase
  end
end

# Returns the letters in the string.
#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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snajam_palindrome-0.1.0 lib/snajam_palindrome.rb