Code Monkey home page Code Monkey logo

bitmap_editor's Introduction

Bitmap Editor

This program is a test, based on this gist file https://gist.github.com/soulnafein/8ee4e60def4e5468df2f.

Running program

To run the program, use the following command ruby runner.rb

You can use the ? as a input for help.

Running specs

To run specs, you can use the rspec command

Explaining the code

I've divided the code into following classes:

  • Pixel: responsible to hold colour information and validations about colour value;
  • Image: responsible to have a matrix of pixels, with operations to set colour or retrieve pixels. It also holds validations of maximum or minimum value for cols and rows;
  • Input: responsible to parse the string from STDIN and validates command type and extra params for the command. This class do not validates the values passed as parameters because Pixel and Image classes are already doing this job;
  • ImageProcessor: get input object and use it's command value to send methods to image, to transform/show image. It's also responsible for doing terminating the app and show help.

BitmapEditor class was refactored to use new classes. It also has a "begin/rescue" block in it because when something wrong occurs, the code raise a error with a message and that is used as a feedback for the user.

bitmap_editor's People

Contributors

skateonrails avatar periclestheo avatar akash avatar fuffi avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.