Threesuns

Email

Contact

All Semesters

Semesters

All Courses

Courses

Ruby

CSYS2853

3 credits

Labs

Tut

Lab

100 points

Requirements

Tut class created10
to_tut and to_english methods are class methods20
English to tut conversion is correct20
Tut to English conversion is correct20
Methods return characters to their blocks10
Test code executes correctly20
Total100 pts

Objective

To practice working with iterators and blocks

Instructions

For this lab you will need to create a Ruby class called Tut. This class should contain two class methods, one called to_tut and the other called to_english.

The to_tut method should accept an english string as an argument to the method and then should pass each of the characters of that string converted to tut (so it may actually be more than one character passed) to a block associated with the method.

The to_english method should receive a string of tut as an argument and then should pass each of the characters of that string converted to english to a block associated with the method.

When your Tut class is working properly you should be able to execute the following test code and have it produce the specified output:

Tut.to_tut( "Wow! Look at this get converted to Tut!" ) { |c| print c }
# should outout : Wutowut! Lutookut atut tuthutisut gutetut cutonutvuteruttutedut tuto Tututut!'

tut_string = ""
Tut.to_tut( "I'm in tut but I want to be in english." ) { |c| tut_string += c }
puts tut_string
# should output : I'mut inut tututut bututut I wutanuttut tuto bute inut enutgutlutisuthut.

Tut.to_english( tut_string ) { |c| print c }
# should output : I'm in tut but I want to be in english.

The Language of Tut

The tut language is a simple encoded language where words are spelled out and the letters "ut" are placed after every constant, vowels are left as they are. So the word "Hello", in tut become "Hutelutluto" The word "Goodbye" becomes "Gutoodutbutyute". The sentence "How are you today?", becomes "Hutowut arute yutou tutodutayut?".