class CW::Play
Public Class Methods
new(words)
click to toggle source
# File lib/cw/play.rb, line 6 def initialize words @words = words end
Public Instance Methods
add_space(words)
click to toggle source
# File lib/cw/play.rb, line 46 def add_space words str = '' words.to_array.collect { |word| str << word + ' '} str end
audio()
click to toggle source
# File lib/cw/play.rb, line 17 def audio @audio ||= AudioPlayer.new end
init_play_words_timeout()
click to toggle source
# File lib/cw/play.rb, line 21 def init_play_words_timeout @start_play_time, @delay_play_time = Time.now, 2.0 end
play()
click to toggle source
# File lib/cw/play.rb, line 52 def play audio.play end
play_audio()
click to toggle source
# File lib/cw/play.rb, line 56 def play_audio audio.convert_words add_space @words start_sync() play end
play_words_exit()
click to toggle source
# File lib/cw/play.rb, line 62 def play_words_exit # puts "play_words_exit" init_play_words_timeout loop do break if quit? break if play_words_timeout? if Cfg.config["exit"] audio.stop break end sleep 0.01 end # Cfg.config["exit"] = true sleep 0.1 end
play_words_timeout?()
click to toggle source
# File lib/cw/play.rb, line 25 def play_words_timeout? (Time.now - @start_play_time) > @delay_play_time end
play_words_until_quit()
click to toggle source
# File lib/cw/play.rb, line 78 def play_words_until_quit play_audio play_words_exit unless Cfg.config["print_letters"] end
quit?()
click to toggle source
# File lib/cw/play.rb, line 10 def quit? if Cfg.config["quit"].nil? Cfg.config.params["quit"] = false Cfg.config["quit"] end end
start_sync()
click to toggle source
# File lib/cw/play.rb, line 29 def start_sync @start_sync = true end
start_sync?()
click to toggle source
# File lib/cw/play.rb, line 33 def start_sync? if @start_sync @start_sync = nil true else nil end end
still_playing?()
click to toggle source
# File lib/cw/play.rb, line 83 def still_playing? audio.still_playing? end
stop()
click to toggle source
# File lib/cw/play.rb, line 87 def stop audio.stop end
wait_player_startup_delay()
click to toggle source
# File lib/cw/play.rb, line 42 def wait_player_startup_delay sleep 0.2 end