Day 38, Part 1: First App Finished

I just finished my Book Tracker app. I decided to only add a print function as I would want to put out the whole list as I go. I may go back eventually to add search, but for what it is for I believe a list function is best. I am using it to track as I go.

I created a video to detail the app and show how it works:

and here is a look at the code. You can also see the code at my GitHub profile.

First, the main file:

and the the file where I create Book.class:

and then the YAML file… where the data is stored.

OK, I am moving on to Ruby on Rails tonight. I will return shortly!

3 thoughts on “Day 38, Part 1: First App Finished

  1. Hey!
    You are doing great, keep it up 🙂 I have some suggestions for you.

    You can simplify your save method to a single line:
    File.write("books.yml", @book_list.to_yaml)

    Here is the relevant documentation for that method:

    Also your add_book method has a lot of repetition, you can simplify it extracting the logic into a method, like this:

    def get_answer(question)
    puts question

    def add_book
    book =
    book.book_title = get_answer "Book title: " = get_answer "Author: "
    book.genre = get_answer "Genre: "
    book.status = get_answer "Have you read it, listened to it, or both? " = get_anser "Write a short, one sentence, review! "

    @book_list << book

    This code makes it a lot easier to add new answers and it also makes it easier to see what’s going on, do you agree? 🙂

    1. Both of these make a lot of sense, especially the simplifying the add_book method. Is “question” being defined somewhere, however, or did I miss something?

Comments are closed.