The Least Boring Programming Book: Chapter 1 (excerpt)
blog.ethanjfast.com
blog.ethanjfast.com
First, and foremost, I'm not sure who your target reader is. Judging by the jargon you use, I'm not sure he exists. Someone who has never programmed before is almost definitely not going to know how to "go back to [his] terminal [and] run the program with the command ruby closet.rb," or even how to "open up a new file called closet.rb in [his] text editor." If he's a Windows user, he probably don't even have Ruby installed. Further, a beginning programer probably does not understand why he cannot easily/should not use Microsoft Word as his text editor.
On the other hand, someone who knows how to do all of this probably understands the basics of programming. I'm not sure they'd want to read this chapter and wade through a few dozen paragraphs of prose to learn how to use the standard input, output, and string concatenation in Ruby. I doubt this is your target reader.
If you're aiming for the first programmer, you probably want a dedicated programming environment to start them off. It could be as simple as a "djinn package" that installs a basic text editor with Ruby syntactical highlights and the command line tools, but a big red "run this program" button on the editor is always nice. You can wean them off of the custom editor later.
Also, you'll almost definitely want to include the most basic an intro to debugging code. A book is non-interactive, and you have to prepare for the event that nobody can say, "Oh, 'Unterminated string meets end of file' means you forgot a double quote here on line 3," to the user. Perhaps have the narrator make a mistake, the genie correct him, and talk about why the computer wants strings to have double quotes. Or something.
It's a great start, but you just need to get past a few more pitfalls.
edit: Fixed a few grammar issues. Also, I'm Math/CS teacher and currently teach 8th through 12th graders.
Another issue that my programming students (university sophomores/juniors in a business school) often have trouble with is the concept of = being used for assignment rather than equality testing. It's as natural as breathing for programmers, but a weird shift from the type of math they're used to.
And then weak typing vs. strong typing vs. what the student expects, but at least that's easy to head off at the pass if you're anticpating it.
Trying to teach programming through narrative storytelling seems counterproductive.