Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/oranga_palindrome.rb
Instance Method Summary collapse
-
#letters ⇒ Object
Returns the letters in the string.
-
#palindrome? ⇒ Boolean
Returns true for a palindrome, false otherwise.
Instance Method Details
#letters ⇒ Object
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.
8 9 10 |
# File 'lib/oranga_palindrome.rb', line 8 def palindrome? processed_content == processed_content.reverse end |