Skip to content

Instantly share code, notes, and snippets.

@rgarro
Created April 25, 2016 16:47
Show Gist options
  • Save rgarro/6d123ffa311e52708243dc61501a35a4 to your computer and use it in GitHub Desktop.
Save rgarro/6d123ffa311e52708243dc61501a35a4 to your computer and use it in GitHub Desktop.
word_count test
# 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