Skip to content

Instantly share code, notes, and snippets.

View colemanfoley's full-sized avatar

Coleman Foley colemanfoley

View GitHub Profile
@colemanfoley
colemanfoley / gist:3747578
Created September 19, 2012 03:50
Numbers into Words
module InWords
#The method for turning integers 1-19 into the appropriate strings.
def under20
array_small_numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
return array_small_numbers[self]
end
#The method for turning integers 20-99 into the appropriate strings.
def under100
@colemanfoley
colemanfoley / gist:3747574
Created September 19, 2012 03:48
Pig Latin translator
#The main method, it takes a string that is an English word and returns that word in Pig Latin.
#All words have "ay" appended to them in the line just before the return statement. If the word
#begins with a vowel, it is sent to the << "ay" line unmodified.
#If it is exactly three letters long, the second two characters of english_word are made the first
#two of pig_latin_word, then the first letter of english_word is made the third character of
#pig_latin_word. Then the word is ready to get the << "ay" treatment.
def translate(english_word)
if is_vowel?(english_word[0])
pig_latin_word = english_word
@colemanfoley
colemanfoley / Pig Latin
Created September 17, 2012 02:31
Translates English word to Pig Latin
#The main method, it takes a string that is an English word and returns that word in Pig Latin.
#All words have "ay" appended to them in the line just before the return statement. If the word
#begins with a vowel, it is sent to the << "ay" line unmodified.
#If it is exactly three letters long, the second two characters of english_word are made the first
#two of pig_latin_word, then the first letter of english_word is made the third character of
#pig_latin_word. Then the word is ready to get the << "ay" treatment.
def translate(english_word)
if is_vowel?(english_word[0])
pig_latin_word = english_word
@colemanfoley
colemanfoley / gist:3725822
Created September 15, 2012 00:37
Dictionary class
class Dictionary
attr_accessor :entries
attr_accessor :keywords
def initialize
@entries = Hash.new
end
def add(entry)
if entry.is_a? Hash