-
-
Save AndrewVos/1212000 to your computer and use it in GitHub Desktop.
example
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
class WordReader | |
def initialize file | |
@file = file | |
end | |
def read_words | |
File.read(@filename).split(/\s+/) | |
end | |
end | |
class CommonWordRemover | |
def initialize common_words | |
@common_words = common_words | |
end | |
def remove_common_words(words) | |
words - common_words | |
end | |
end | |
class WordPresenter | |
def initialize words | |
@words = words | |
end | |
def present_words | |
puts @words | |
end | |
end | |
all_words = words = WordReader.new("filename.txt").read_words | |
uncommon_words = CommonWordRemove.new(["at", "and", "the"]).remove_common_words(all_words) | |
WordPresenter.new(words).present_words |
Author
AndrewVos
commented
Sep 12, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment