Skip to content

Instantly share code, notes, and snippets.

@gilcierweb
Last active February 24, 2016 02:21
Show Gist options
  • Save gilcierweb/f512be547434e2ca5577 to your computer and use it in GitHub Desktop.
Save gilcierweb/f512be547434e2ca5577 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# test gilcier
# In terminal execute ruby palindrome.rb
class String
def initialize(word)
@word = word.to_s.strip.downcase
end
def verify_word
if(@word == @word.reverse)
puts "#{@word} word is a palindrome!"
else
puts "#{@word} word is not a palindrome!"
end
end
end
puts "Tell how many words you want to check if it is a palindrome"
quantity = gets.to_s.strip.downcase.chomp
for count_current in 1..quantity.to_i do
puts "Enter a word ##{count_current}"
word = gets.to_s.strip.downcase.chomp
# Use
palindrome = String.new(word)
palindrome.verify_word
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment