Class: CWG::Tx

Inherits:
Tester show all
Defined in:
/Users/martyn/cw/cw_clone/lib/cw/tx.rb

Instance Method Summary (collapse)

Methods inherited from Tester

#add_space, #audio, #audio_play, #audio_stop, #check_quit_key_input, #complete_word?, #current_word, #do_events, #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_words_exit, #play_words_thread, #play_words_until_quit, #print, #print_failed_exit_words, #print_letters?, #print_words, #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, #spawn_play, #start_sync, #start_sync?, #stream, #sync_with_audio_player, #sync_with_play, #sync_with_print, #timing, #wait_for_no_word_process, #wait_for_start_sync, #wait_player_startup_delay, #word_proc_timeout

Instance Method Details

- (Object) echo



42
43
44
45
46
47
48
49
50
51
52
53
54
# File '/Users/martyn/cw/cw_clone/lib/cw/tx.rb', line 42

def echo
  loop do
    @temp ||= ''
    if @temp != ''
      puts "@temp = #{@temp}"
      chr = @temp.shift
      puts "chr = #{chr}"
      @audio.convert_words(chr)
      @audio.play
    end
    sleep 0.1
  end
end

- (Object) read



11
12
13
14
15
16
17
# File '/Users/martyn/cw/cw_clone/lib/cw/tx.rb', line 11

def read
  loop do
    key_input.read
    @temp << key_chr if is_relevant_char?
    sleep 0.1
  end
end

- (Object) run



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File '/Users/martyn/cw/cw_clone/lib/cw/tx.rb', line 19

def run
  @audio = AudioPlayer.new

  @cw_threads = CWThreads.new(self, thread_processes)
  @cw_threads.run

#      loop do
#      @temp = STDIN.gets
#        temp = "one two three four five six seven eight nine ten"

#      @temp.gsub!("\n",' ')
#        temp.gsub!(' ','')


#        @cw_threads = CWThreads.new(self, thread_processes)
#        @cw_threads.run
#        reset_stdin
#        print.newline

#                start_sync()
#      end
end

- (Object) thread_processes



4
5
6
7
8
9
# File '/Users/martyn/cw/cw_clone/lib/cw/tx.rb', line 4

def thread_processes
  [
    :read,
    :echo
  ]
end