class CW::Cl
class Cl
performs command-line processing
Public Class Methods
new()
click to toggle source
# File lib/cw/cl.rb, line 11 def initialize @tone = { sinewave: 0, sawtooth: 1, squarewave: 2 } end
Public Instance Methods
build_command_line()
click to toggle source
# File lib/cw/cl.rb, line 97 def build_command_line [ cl_wpm, cl_effective_wpm, cl_word_spacing, cl_frequency, cl_squarewave, cl_sawtooth, cl_sinewave, cl_author, cl_title, cl_noise, cl_audio_filename, cl_quality, cl_command_line ].collect{|param| param}.join end
cl_audio_filename()
click to toggle source
# File lib/cw/cl.rb, line 71 def cl_audio_filename "-o \"#{File.join(audio_dir, audio_filename)}\" " end
cl_command_line()
click to toggle source
# File lib/cw/cl.rb, line 92 def cl_command_line cl = Cfg.config["command_line"] cl ? "#{cl}" : '' end
cl_echo(words)
click to toggle source
# File lib/cw/cl.rb, line 118 def cl_echo words "echo #{words} | #{ebook2cw_path} #{build_command_line}" end
cl_effective_wpm()
click to toggle source
# File lib/cw/cl.rb, line 24 def cl_effective_wpm ewpm = Cfg.config["effective_wpm"] ewpm ? "-e #{ewpm} " : '' end
cl_frequency()
click to toggle source
# File lib/cw/cl.rb, line 34 def cl_frequency freq = Cfg.config["frequency"] freq ? "-f #{freq} " : '' end
cl_full(input)
click to toggle source
# File lib/cw/cl.rb, line 122 def cl_full input "#{ebook2cw_path} #{build_command_line} #{input}" end
cl_noise()
click to toggle source
# File lib/cw/cl.rb, line 66 def cl_noise Cfg.config["noise"] ? "-N 10 -B 800 " : '' end
cl_quality()
click to toggle source
# File lib/cw/cl.rb, line 83 def cl_quality quality = Cfg.config["quality"] if quality && quality.class == 1.class "-q #{quality} " else coarse_quality quality end end
cl_sawtooth()
click to toggle source
# File lib/cw/cl.rb, line 48 def cl_sawtooth wave "sawtooth" end
cl_sinewave()
click to toggle source
# File lib/cw/cl.rb, line 52 def cl_sinewave wave "sinewave" end
cl_squarewave()
click to toggle source
# File lib/cw/cl.rb, line 44 def cl_squarewave wave 'squarewave' end
cl_title()
click to toggle source
# File lib/cw/cl.rb, line 61 def cl_title title = Cfg.config["title"] title ? "-t \"#{title}\" " : '' end
cl_word_spacing()
click to toggle source
# File lib/cw/cl.rb, line 29 def cl_word_spacing ws = Cfg.config["word_spacing"] ws ? "-W #{ws} " : '' end
cl_wpm()
click to toggle source
# File lib/cw/cl.rb, line 19 def cl_wpm wpm = Cfg.config["wpm"] wpm ? "-w #{wpm} " : '' end
coarse_quality(quality)
click to toggle source
# File lib/cw/cl.rb, line 75 def coarse_quality(quality) { :high => "-q 1 ", :medium => "-q 5 ", :low => "-q 9 " }[quality] end
ebook2cw_path()
click to toggle source
# File lib/cw/cl.rb, line 114 def ebook2cw_path Cfg.config["ebook2cw_path"] || 'ebook2cw' end
wave(type)
click to toggle source
# File lib/cw/cl.rb, line 39 def wave type return '' unless(Cfg.config["tone"].to_s == type) "-T #{@tone[type.to_sym]} " end