Created
October 27, 2012 09:37
-
-
Save kennyt/3963770 to your computer and use it in GitHub Desktop.
03_simon_says
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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