Our site uses cookies. Learn more about their purpose and change of settings in a browser If you are using the site, you give you consent to use cookies, according to current browser settings. Got it

Ruby Transformations

  • Language Ruby
Create a method to accept a string as an argument, and return a string of length 26.

Ruby Transformations

Exercise 1

Create a method to accept string as an argument, and return a string of length 26.

The objective is to detect if the letters of the English alphabet (upper or lower case) are present anywhere in the string, and to set each of the 26 characters corresponding to each letter to either '1' if present or '0' if not.

So if an 'a' or an 'A' appears anywhere in the argument string (any number of times), set the first character of the returned string to '1' otherwise to '0', if 'b' or 'B' appear, set the second to '1', and so on for the rest of the alphabet.

So the returned string consists only of '1's and '0's.

letter_occurance_check("abcz") # => "11100000000000000000000001"

When nil or blank string is given it should return string with all 0.

Exercise 2

Create a sum_args method which sums all the given arguments

Exercise 3

Create two methods: - tocamelcase which changes underscore case string to a camelcase string to_camel_case("this_is_string") => "thisIsString"

  • tocapitalcase which changes underscore case string to a capitalized case string to_capital_case("this_is_string") => "ThisIsString"

Exercise 4

Implement a prepareimagedetails method which accepts imageid and imagedata as a hash

prepare_image_details(10, image_data)


        "original" => {"format"=>"jpg", "geometry"=>"1440x900"},
        IMAGE_TYPE => { "format" => jpeg|jpg|png , "geometry" => WIDTHxHEIGHT },

The result:

        width: 1440, height: 900, content_type: "image/jpeg", image_type: "original",
        image_url: "http://images_server.com/images/10/original.jpg"
        width: WIDTH, height: HEIGHT, content_type: "image/jpeg|png", image_type: IMAGE_TYPE,
        image_url: "http://images_server.com/images/10/IMAGE_TYPE.format"
      }, ...

Requirements: - imageurl: `"http://imagesserver.com/images/IMAGEID/IMAGETYPE.FORMAT" - content_type:image/pngforpngformat,image/jpegforjpeg|jpg` formats


To install dependencies

bundle install

To run tests

To run tests execute

rake verify

Good luck!

Start this test

I agree to subscription in accordance with the terms of service.
Go to the top and begin