Created
April 25, 2016 16:47
-
-
Save rgarro/6d123ffa311e52708243dc61501a35a4 to your computer and use it in GitHub Desktop.
word_count test
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
# Word count Module | |
# | |
# | |
# @author Rolando Garro <rgarro@gmail.com> | |
# | |
module Wc | |
@testStr = "Darkness in a blink engine mantra roaring storm gray evening raindrops in a rain gray spot" | |
class wordBox | |
@@word = "" | |
@@times = 1 | |
def initialize(word) | |
@@word = word | |
end | |
end | |
class counter | |
@@uniques = [] | |
@@result = [] | |
def initialize(paragrap) | |
@parts = paragrap.split(" ") | |
@parts.each do|i| | |
if uniques.index(i) > 0 | |
@@result[uniques.index(i)].times = @@result[uniques.index(i)].times + 1 | |
else | |
@@result.push(Wc.wordBox.new(i)) | |
@@uniques.push(i) | |
end | |
end | |
end | |
end | |
def self.auto_test | |
@tmp = Wc.counter.new(Wc.testStr) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment