Class: ObfuscatedMorseCode::MorseCodeObfuscator

Inherits:
Object
  • Object
show all
Defined in:
lib/obfuscated_morse_code/morse_code_obfuscator.rb

Constant Summary collapse

DASH_OBFUSCATION_DICTIONARY =
%w[A B C D E].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(morse_codes) ⇒ MorseCodeObfuscator

Returns a new instance of MorseCodeObfuscator.



9
10
11
# File 'lib/obfuscated_morse_code/morse_code_obfuscator.rb', line 9

def initialize(morse_codes)
  @morse_codes = morse_codes
end

Instance Attribute Details

#morse_codesObject (readonly)

Returns the value of attribute morse_codes.



7
8
9
# File 'lib/obfuscated_morse_code/morse_code_obfuscator.rb', line 7

def morse_codes
  @morse_codes
end

Instance Method Details

#obfuscateObject



13
14
15
16
17
18
# File 'lib/obfuscated_morse_code/morse_code_obfuscator.rb', line 13

def obfuscate
  morse_codes.map do |code|
    obfuscated = replace_dots_with_numbers(code)
    replace_dashes_with_characters(obfuscated)
  end
end