class String

Public Instance Methods

letters() click to toggle source

Returns the letters in the string.

# File lib/tchia04_palindrome.rb, line 11
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
palindrome?() click to toggle source

Returns true for a palindrome, false otherwise.

# File lib/tchia04_palindrome.rb, line 6
def palindrome?
  processed_content == processed_content.reverse
end

Private Instance Methods

processed_content() click to toggle source

Returns content for palindrome testing.

# File lib/tchia04_palindrome.rb, line 25
    def processed_content
      self.scan(/[a-z]/i).join.downcase

#      self.letters.downcase
    end