Class: ObfuscatedMorseCode::MorseCodeTranslator
- Inherits:
-
Object
- Object
- ObfuscatedMorseCode::MorseCodeTranslator
- Defined in:
- lib/obfuscated_morse_code/morse_code_translator.rb
Instance Attribute Summary collapse
-
#letter_separator ⇒ Object
readonly
Returns the value of attribute letter_separator.
-
#word_separator ⇒ Object
readonly
Returns the value of attribute word_separator.
Instance Method Summary collapse
-
#initialize(letter_separator: '|', word_separator: '/') ⇒ MorseCodeTranslator
constructor
A new instance of MorseCodeTranslator.
- #translate(sentences) ⇒ Object
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_separator ⇒ Object (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_separator ⇒ Object (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 |