Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Forked from Phrogz/example.rb
Created September 12, 2011 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewVos/1212000 to your computer and use it in GitHub Desktop.
Save AndrewVos/1212000 to your computer and use it in GitHub Desktop.
example
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
@AndrewVos
Copy link
Author

Troll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment