Class: CWG::Cl

Inherits:
Object
  • Object
show all
Defined in:
/Users/martyn/cw/cw_clone/lib/cw/cl.rb

Overview

class Cl performs command-line processing

Instance Method Summary (collapse)

Constructor Details

- (Cl) initialize

Returns a new instance of Cl



9
10
11
12
13
14
15
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 9

def initialize
  @tone = {
    sinewave: 0,
    sawtooth: 1,
    squarewave: 2
  }
end

Instance Method Details

- (Object) build_command_line



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 93

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

- (Object) cl_audio_filename



67
68
69
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 67

def cl_audio_filename
  "-o \"#{File.expand_path(Params.audio_filename, Params.audio_dir)}\" "
end

- (Object) cl_author



52
53
54
55
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 52

def cl_author
  author = Params.author
  author ? "-a \"#{author}\" " : ''
end

- (Object) cl_command_line



88
89
90
91
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 88

def cl_command_line
  cl = Params.command_line
  cl ? "#{cl}" : ''
end

- (Object) cl_echo(words)



115
116
117
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 115

def cl_echo words
  "echo #{words} | #{ebook2cw_path} #{build_command_line}"
end

- (Object) cl_effective_wpm



22
23
24
25
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 22

def cl_effective_wpm
  ewpm = Params.effective_wpm
  ewpm ? "-e #{ewpm} " : ''
end

- (Object) cl_frequency



32
33
34
35
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 32

def cl_frequency
  freq = Params.frequency
  freq ? "-f #{freq} " : ''
end

- (Object) cl_full(input)



119
120
121
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 119

def cl_full input
  "#{ebook2cw_path} #{build_command_line} #{input}"
end

- (Object) cl_noise



62
63
64
65
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 62

def cl_noise
  noise = Params.noise
  noise ? "-N 5 -B 1000 " : ''
end

- (Object) cl_quality



79
80
81
82
83
84
85
86
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 79

def cl_quality
  quality = Params.quality
  if quality && quality.class == Fixnum
    "-q #{quality} "
  else
    coarse_quality quality
  end
end

- (Object) cl_sawtooth



42
43
44
45
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 42

def cl_sawtooth
  st = Params.tone == :sawtooth
  st ? "-T #{@tone[:sawtooth]} " : ''
end

- (Object) cl_sinewave



47
48
49
50
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 47

def cl_sinewave
  sin = Params.tone == :sinewave
  sin ? "-T #{@tone[:sinewave]} " : ''
end

- (Object) cl_squarewave



37
38
39
40
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 37

def cl_squarewave
  sqr = Params.tone == :squarewave
  sqr ? "-T #{@tone[:squarewave]} " : ''
end

- (Object) cl_title



57
58
59
60
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 57

def cl_title
  title = Params.title
  title ? "-t \"#{title}\" " : ''
end

- (Object) cl_word_spacing



27
28
29
30
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 27

def cl_word_spacing
  ws = Params.word_spacing
  ws ? "-W #{ws} " : ''
end

- (Object) cl_wpm



17
18
19
20
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 17

def cl_wpm
  wpm = Params.wpm
  wpm ? "-w #{wpm} " : ''
end

- (Object) coarse_quality(quality)



71
72
73
74
75
76
77
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 71

def coarse_quality(quality)
  {
    :high =>   "-q 1 ",
    :medium => "-q 5 ",
    :low =>    "-q 9 "
  }[quality]
end

- (Object) ebook2cw_path



110
111
112
113
# File '/Users/martyn/cw/cw_clone/lib/cw/cl.rb', line 110

def ebook2cw_path
  Params.ebook2cw_path ||= 'ebook2cw'
  Params.ebook2cw_path
end