Skip to content

Instantly share code, notes, and snippets.

@blaisethomas
Last active August 29, 2015 14:18
Show Gist options
  • Save blaisethomas/197bd9e82afb4cd2c877 to your computer and use it in GitHub Desktop.
Save blaisethomas/197bd9e82afb4cd2c877 to your computer and use it in GitHub Desktop.

Ruby smoothie maker

1. Create a method 'blend' that takes an array of ingredients and returns a mixed string of characters, with NO spaces

2. Create a class called Blender, and define the blend method within this class

3. Blend the ingredients array

4. Challenge add on: Give the blender an on and off switch and only allow the blender to function when it's on.

FOR SAFETY'S SAKE When you create a new blender (initialize) by default it should be off.

5. Blend the ingredients array again, first making use of the new safety feature (ie don't forget to switch the blender on!).

EXAMPLE: ingredients = ['carrot', 'celery', 'orange', 'banana', 'green apple'] Blender.new.blend(ingredients) will return something like: "ornecaeprgoaclenygptnaenerrrleaaba"

Sample tests: Your Ruby code should be able to pass the following tests:

it 'Should be off when created'

it 'Should have a method to switch it on'

it 'Should have a method to switch it off'

it 'Should return a blended string'

it 'Should not have spaces in the returned string'

it 'Does not blend if switched off'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment