class CW::Timing
Attributes
delay_time[RW]
start_time[RW]
Public Class Methods
new()
click to toggle source
# File lib/cw/timing.rb, line 9 def initialize @delay_time = 0.0 @cw_encoding = Encoding.new end
Public Instance Methods
append_char_delay(letr, wpm, ewpm)
click to toggle source
# File lib/cw/timing.rb, line 81 def append_char_delay letr, wpm, ewpm @delay_time += char_delay(letr, wpm, ewpm) end
char_delay(char, wpm, ewpm)
click to toggle source
# File lib/cw/timing.rb, line 72 def char_delay(char, wpm, ewpm) @wpm, @effective_wpm = wpm, ewpm if(char != ' ') char_timing(cw_encoding(char)) unless(char == ' ') else space_timing end end
char_delay_timeout?()
click to toggle source
# File lib/cw/timing.rb, line 42 def char_delay_timeout? (Time.now - @start_time) > @delay_time end
char_timing(* args)
click to toggle source
# File lib/cw/timing.rb, line 46 def char_timing(* args) timing = 0 args.flatten.each do |arg| case arg when :dot then timing += 2 when :dash then timing += 4 else puts "Error! invalid morse symbol - was #{arg}" end end timing -= 1 timing = timing.to_f * dot_ms timing + code_space_timing end
code_space_timing()
click to toggle source
# File lib/cw/timing.rb, line 61 def code_space_timing @effective_wpm ? 3.0 * effective_dot_ms : 3.0 * dot_ms end
cw_encoding(enc)
click to toggle source
# File lib/cw/timing.rb, line 14 def cw_encoding enc @cw_encoding.fetch(enc) end
dot(wpm)
click to toggle source
# File lib/cw/timing.rb, line 18 def dot wpm 1.2 / wpm.to_f end
dot_ms()
click to toggle source
# File lib/cw/timing.rb, line 22 def dot_ms dot @wpm end
effective_dot_ms()
click to toggle source
# File lib/cw/timing.rb, line 34 def effective_dot_ms dot @effective_wpm end
init_char_timer()
click to toggle source
# File lib/cw/timing.rb, line 38 def init_char_timer @start_time, @delay_time = Time.now, 0.0 end
init_print_words_timeout()
click to toggle source
# File lib/cw/timing.rb, line 26 def init_print_words_timeout @start_print_time, @delay_print_time = Time.now, 2.0 end
print_words_timeout?()
click to toggle source
# File lib/cw/timing.rb, line 30 def print_words_timeout? (Time.now - @start_print_time) > @delay_print_time end
space_timing()
click to toggle source
# File lib/cw/timing.rb, line 66 def space_timing space = 4.0 @effective_wpm ? space * effective_dot_ms : space * dot_ms end