Movie Box
a ruby terminal app
What is Movie Box? 🎬
MovieBox is a ruby powered CLI app that allows users to catalogue and record all the movies they have seen.
Functionalities include adding movie, deleting movie and updating movie.
App Preview
1. Movie Box home page
The heart of this application is CRUD. (Create, Read, Update, Delete)
The main menu of this app is:
Add Movies
Display Movies
Delete Movies
Update Movies
The exit option will end the program.
The Menu options UI throughout the app is a gem, (basically a package) called tty-prompt. The version used here is 0.23.0
2. Add Movie Functionality
Adding a movie is simply about answering the prompted questions:
- Name of movie and released year of movie
The programs then checks for duplicates using these two information provided. If duplicates found, program informs user and program starts again. If no duplicates found, we resume the program.
- Ranking (user can come up with their own ranking, it is arbitrary)
- Name of director(s) and actor(s) or actress(es)
- Movie genre, then rating and a comment to go with the rating.
Ruby Code - used three separate functions as explained below.
Ruby makes it very easy to add to array. The syntax ('<<') means to append item to the end of the array.
3. Delete Movie Functionality
Deleting a movie was the simplest and easiest functionality implemented. Program only needs:
- Name of movie and released year of the movie
Ruby Code - one function takes two parameters. Code performs a check against the local records.
The program will retrieve from the records and display the movie, then ask for confirmation to delete the movie.
Note: The gem used to make this table is called terminal-table. Version used here is 3.0.0
4. Update Movie Functionality
The code for updating the movie follows this logic.
1. Find the movie with the name and year information. Then make a COPY of it.
2. DELETE the old movie. It's okay we kept an old copy.
3. Now perform the update to the copied data.
4. Save the data.
The downside to this is that the newly updated item is pushed to the end of the data array. This could be improved.