Class: ObfuscatedMorseCode::MorseCodeTranslator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letter_separator: '|', word_separator: '/') ⇒ MorseCodeTranslator

Returns a new instance of MorseCodeTranslator.



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

def initialize(letter_separator: '|', word_separator: '/')
  @letter_separator = letter_separator
  @word_separator = word_separator
end

Instance Attribute Details

#letter_separatorObject (readonly)

Returns the value of attribute letter_separator.



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

def letter_separator
  @letter_separator
end

#word_separatorObject (readonly)

Returns the value of attribute word_separator.



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

def word_separator
  @word_separator
end

Instance Method Details

#translate(sentences) ⇒ Object



14
15
16
17
18
19
# File 'lib/obfuscated_morse_code/morse_code_translator.rb', line 14

def translate(sentences)
  sentences.map do |sentence|
    letters = sentence.split('')
    translate_letters(letters)
  end
end