I am trying to write a little Ruby program that can insert two letters behind consonants only within a string. I’m trying to do it using two classes within a main class by passing the characters of a string to the block associated with the class method. One method would insert the letters, the other would be able to remove them.
Here’s what I have so far:
class Mytranslator
def to_mytrans( string )
letters = string.inject( 'it' ) {|letters, char| collection += char}
puts letters
end
def to_normaltrans( string )
end
end
Problem is, I don’t know if I’m even on the right track. And I have no idea how to write the second method. Any help would be greatly appreciated. Thanks.
This will fail if your string has numbers/punctuation etc.