Skip to content

Instantly share code, notes, and snippets.

@kennyt
Created October 27, 2012 09:37
Show Gist options
  • Save kennyt/3963770 to your computer and use it in GitHub Desktop.
Save kennyt/3963770 to your computer and use it in GitHub Desktop.
03_simon_says
def echo (word)
word
end
def shout (word)
word.upcase
end
def repeat (word, times = 2)
(word * times).gsub(word, " #{word}").strip
end
def start_of_word (word, number)
word.slice(0..number-1)
end
def first_word (string)
string.split(' ').first
end
def titleize (title)
small_words = %w{and the over in how why it then was oh}
title.capitalize!
title.split(' ').each { |word| word.capitalize! unless small_words.include?(word) }.join(" ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment