summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xspelling-rbee54
1 files changed, 29 insertions, 25 deletions
diff --git a/spelling-rbee b/spelling-rbee
index bff49a6..1c79af0 100755
--- a/spelling-rbee
+++ b/spelling-rbee
@@ -11,14 +11,6 @@ def say(it,speed=100)
system "espeak -s #{speed} '#{it}'"
end
-def ckopt(word, result)
- case result
- when ":r" then say word
- when ":imacheaterandknowit" then puts word
- when ":q" then $exit = true
- end
-end
-
def ckword(word,result)
if result == word
return [word, "correct", result]
@@ -34,34 +26,46 @@ def read(file)
end
def repl(words)
- correct = []
- words.each {|word|
+ results = []
+ words.each do |word|
say word
result = get
- until result[0] != ":"
- ckopt(word,result)
- if $exit
- return $exit
- end
- result = get
+ # while result[0] == ":"
+ # ckopt(word,result)
+ # if $exit
+ # return $exit
+ # end
+ # result = get
+ # end
+ case result
+ when ":r"
+ redo
+ when ":imacheaterandknowit"
+ puts word
+ redo
+ when ":q"
+ $exit = true
end
- correct.push ckword(word,result)
- }
- return correct
+ break if $exit
+ results.push ckword(word,result)
+ end
+ return results
end
-def rcorrect(words)
- correct = []
+def results(words)
+ results = []
words.each {|word|
- correct.push(word[0] + ": " + word[1] + ": " + word[2])
+ results.push(word[0] + ": " + word[1] + ": " + word[2])
}
return correct
end
-def run(file)
+def run(file = (ARGV[0] || "http://zoar.cx/~simon/21k/words.txt"))
+ $exit = false
words = read file
correct = repl words
- puts rcorrect correct unless correct == true
+ return true if $exit
+ puts results results
end
-run (ARGV[0] || "http://zoar.cx/~simon/21k/words.txt")
+run