Class: MorseCode::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/morse_code/cli.rb

Instance Method Summary collapse

Instance Method Details

#decode(message = '') ⇒ Object



29
30
31
32
33
34
35
# File 'lib/morse_code/cli.rb', line 29

def decode(message = '')
  if options[:dit_dah]
    puts MorseCode::Decoder.new(message).dit_dah_to
  else
    puts MorseCode::Decoder.new(message).decode
  end
end

#encode(message = '') ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/morse_code/cli.rb', line 14

def encode(message = '')
  encoder = MorseCode::Encoder.new(message)
  if options[:dit_dah]
    puts encoder.dit_dah
  else
    puts encoder.encode
  end
  if options[:wave]
    wavefile = encoder.wave
    puts "Generate wave file: #{wavefile}"
  end
end