Code Monkey home page Code Monkey logo

easycrumbs's People

Contributors

grafikchaos avatar lte avatar staszek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

grafikchaos

easycrumbs's Issues

Setup new project

  • Create new directory at the root of this project. Name it basics.
  • Download file with tests and put it into folder.
  • Run tests and see if script is working: ruby tests.rb.

Create article class

Please create Article class. It should have 6 instance values with setters and getters.

  • title - Getter
  • body - Getter
  • author - Getter
  • created_at - Getter
  • likes - Getter and Setter
  • dislikes - Getter and Setter

Save articles to disk

The save method should accept an array of articles and save them as a files.

  • File name is a downcase title with spaces changed to _. Extensions is .article
  • File body contain author, likes, dislikes and body separated by ||

Create WebPage

Please create WebPage class.

  • Constructor should accept only one parameter.
  • The directory with .article files. If it is not passed when creating new object use / path by default.
  • It should also load all articles from directory in constructor and set @articles instance variable.
  • Please also add load and save methods to load and save articles from files.
  • Add new_article method to create new articles.

Points calculator

Please add those 4 methods:

  • like! – increment number of likes
  • dislike! – increment number of dislikes
  • points – number of likes minus number of dislikes
  • votes – number of likes plus number of dislikes

Authors

Please create those 4 methods

  • votes - return sum of votes from all articles
  • authors - return array of author
  • authors_statistics - return hash where author is a key and number of its articles is a value. Something like: 'John' => 3, 'Alice' => 1
  • best_author - return author with the most articles

Fetching articles

Please create 6 methods to get articles in different ways:

  • longest_articles – return array of articles sorted by longest one
  • best_articles – return array of articles sorted by points
  • worst_articles – the same as above but reversed
  • best_article – return article with the most points. Raise NoArticlesFound exception if web page does not have any articles
  • worst_article – return article with the less points. Raise NoArticlesFound exception if web page does not have any articles
  • most_controversial_articles – return array of articles sorted by votes

Try Ruby

Visit interactive tutorial at tryruby.org and finish it.

Create constructor

Constructor should accept 3 parameters: title, body, author. Please make the 3rd obsolete to allow create an article without an author. Constructor should also set created_at variable to current time. Number of likes and dislikes should be set to 0

Loads articles from disk

It should find all .article files in directory and returns an array of articles read from disk

Body methods

Please add those 4 methods:

  • long_lines – returns an array of lines longer than 80 signs
  • length – returns length of a body
  • truncate – accepts limit as an argument. If body is longer than limit this method should cut the body and insert ... at the end. Returned string should never be longer than limit.
  • contain? – returns true if body contain a given string or regexp

Searching

search(query) method should return only articles which contains the query. Argumen can be a string or regexp.

Try git

Visit interactive tutorial at try.github.com and finish it

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.