Skip to content

Instantly share code, notes, and snippets.

@theonlyrao
Created February 27, 2016 19:58
Show Gist options
  • Save theonlyrao/58241398b477c3dbcda7 to your computer and use it in GitHub Desktop.
Save theonlyrao/58241398b477c3dbcda7 to your computer and use it in GitHub Desktop.
after using objects
class Write
...
def translate(english_array)
english_array.each do |element|
if element.to_i.to_s == element
@number = Number.new(element)
push_one(@number.number1)
push_two(@number.number2)
push_three(@number.number3)
elsif element.downcase == element
@word = Word.new(element)
push_one(@word.word1)
push_two(@word.word2)
push_three(@word.word3)
else
@cap_word = CapWord.new(element)
push_one(@cap_word.cap_word1)
push_two(@cap_word.cap_word2)
push_three(@cap_word.cap_word3)
end
end
end
end
class Number
def initialize(number)
@dictionary = Dictionary.new
translate_number(number)
end
def translate_number(number)
@digits = number.chars.map do |char|
@dictionary.etb[char]
end
@braille_number = @digits.unshift(@dictionary.etb["#"])
format_number(@braille_number)
end
def format_number(number)
if number[-1] != @dictionary.etb["."]
@braille_number << @dictionary.etb[" "]
end
make_matrix(@braille_number)
end
def make_matrix(number)
number_matrix = BrailleMatrix.new(number)
@number1 = number_matrix.line1
@number2 = number_matrix.line2
@number3 = number_matrix.line3
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment