Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/oranga_palindrome.rb

Instance Method Summary collapse

Instance Method Details

#lettersObject

Returns the letters in the string.



13
14
15
16
17
18
19
20
21
22
# File 'lib/oranga_palindrome.rb', line 13

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?Boolean

Returns true for a palindrome, false otherwise.

Returns:

  • (Boolean)


8
9
10
# File 'lib/oranga_palindrome.rb', line 8

def palindrome?
  processed_content == processed_content.reverse
end