Sha256: add52fe928268a253580364e6fe2061f5bc317edb3b1b76fa5dbcc80b8adb6d9

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

require "cspeezy_palindrome/version"

class String

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

  def letters
    letters = []
    for i in (0..self.length - 1) do
      if self[i].match(/[a-zA-Z]/)
        letters << self[i]
      end
    end
    letters.join
  end

  private

    # Returns content for palindrome testing.
    def processed_content
      self.letters.downcase
    end
end

# module CspeezyPalindrome
#   class Error < StandardError; end
#   # Your code goes here...
# end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cspeezy_palindrome-0.3.0 path/ruby/2.6.0/gems/cspeezy_palindrome-0.1.0/lib/cspeezy_palindrome.rb
cspeezy_palindrome-0.2.0 path/ruby/2.6.0/gems/cspeezy_palindrome-0.1.0/lib/cspeezy_palindrome.rb
cspeezy_palindrome-0.1.0 path/ruby/2.6.0/gems/cspeezy_palindrome-0.1.0/lib/cspeezy_palindrome.rb