Class: CW::RepeatWord
Instance Method Summary
collapse
Methods inherited from Tester
#audio_stop, #complete_word?, #current_word, #cw_threads, #do_events, #exit!, #exit?, #failed!, #failed?, #finish?, #get_key_input, #get_word_last_char, #init_char_timer, #is_relevant_char?, #key_chr, #key_input, #kill_threads, #monitor_keys, #monitor_keys_thread, #move_word_to_process, #play, #play_words_thread, #print, #print_failed_exit_words, #print_letters?, #print_words_exit, #print_words_thread, #print_words_until_quit, #process_letters, #process_space_maybe, #process_word_maybe, #process_words, #push_letter_to_current_word, #quit, #quit?, #quit_key_input?, #reset_stdin, #sleep_char_delay, #stream, #sync_with_audio_player, #sync_with_play, #sync_with_print, #thread_processes, #timing, #wait_for_no_word_process, #wait_for_start_sync, #word_proc_timeout
Instance Method Details
#build_word_maybe ⇒ Object
37
38
39
40
41
|
# File 'lib/cw/repeat_word.rb', line 37
def build_word_maybe
@input_word ||= ''
@input_word << key_chr if is_relevant_char?
move_word_to_process if complete_word?
end
|
#print_marked_maybe ⇒ Object
48
49
50
51
|
# File 'lib/cw/repeat_word.rb', line 48
def print_marked_maybe
@popped = stream.pop_next_marked
print.results(@popped, :pass_only) if(@popped && ! print_letters?)
end
|
#print_words(words) ⇒ Object
def print_failed_exit_words
until stream.stream_empty?
word = stream.pop[:value]
end
puts "empty!"
end
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/cw/repeat_word.rb', line 15
def print_words words
timing.init_char_timer
(words.to_s + ' ').each_char do |letr|
process_letter letr
loop do
do_events
process_space_maybe letr
process_word_maybe
break if timing.char_delay_timeout?
end
print.success letr if print_letters?
end
end
|
29
30
31
32
33
34
35
|
# File 'lib/cw/repeat_word.rb', line 29
def process_input_word_maybe
if @word_to_process
stream.match_last_active_element @process_input_word.strip
@process_input_word = @word_to_process = nil
end
end
|
#process_letter(letr) ⇒ Object
43
44
45
46
|
# File 'lib/cw/repeat_word.rb', line 43
def process_letter letr
current_word.process_letter letr
sleep_char_delay letr
end
|
#run(words) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/cw/repeat_word.rb', line 64
def run words
temp_words = words.all
temp_words.each do |word|
loop do
Cfg.config.params["exit"] = false
break if test_env
@input_word, @words = '', Words.new
Cfg.config.params["quit"] = false
@words.assign word
threads.run
@play = nil
system("stty -raw echo")
break unless failed?
end
end
Cfg.config.params["exit"] = true
end
|
#test_env ⇒ Object
53
54
55
56
57
58
|
# File 'lib/cw/repeat_word.rb', line 53
def test_env
if(ENV["CW_ENV"] == "test")
@words = []
return true
end
end
|
#threads ⇒ Object
60
61
62
|
# File 'lib/cw/repeat_word.rb', line 60
def threads
threads ||= Threads.new(self, thread_processes)
end
|