Let's start writing Ruby code.
So first things first, head over to your terminal.
And yours will look similar.
It'll have a different name here flat planet is the name of my PC.
No, I don't think the world is flat.
I just find it hilarious.
Some people do.
But whatever your username is, your computer name is, that will show up there.
So, the first thing we need to do is create a directory to hold all the files
that we're going to make throughout this course.
So type mkdir, and we want to put it in the C drive,
and let's call it rubycourse.
You can name it anything you want, but we're doing a Ruby course here.
Now, mkdir command will be the same if you're on Linux or a Mac.
But if you're on a Mac, obviously you're not going to type in C because Mac don't
have C drives, they have a different file structure.
Just go ahead and save it anywhere you want on your computer, but
make note of that so you can find it later.
Next, head over to our Sublime Text Editor.
And we want to go over to project, and add folder to project.
And then just navigate to your C drive, and find that directory we just created.
So we called it rubycourse there it is, single-click it to highlight it, and
click Select Folder.
And you see boom, it pops right up.
Now there's nothing in this directory yet.
So let's go ahead and create a file and save it.
So we've got a file that's already been opened, it's untitled.
So just head over here and click File > Save As.
And, again, navigate to your C drive and find that directory again,
that rubycourse, and double-click it.
And now let's name this file hello.rb.
And remember, all Ruby files end in .rb, it stands for Ruby.
That's how the computer knows that your program is a Ruby program, and
we're good to go.
Let's create a first Ruby program.
So just come over here and type puts and
in quotation marks Hello world.
Now go ahead and save this Ctrl + S on a PC, Cmd + S on a Mac or
you can just come over here and click File > Save.
Now we need to run this.
So let's head back over to our terminal.
And if we type in pwd, you can see we're currently in c/users/flatplanet.
And to run this file, we can run it from anywhere, but
it's easiest to run it from in the directory where the file is.
So we need to change into the directory cd change directory.
And we want to change into c/rubycourse, that's the directory we created.
And you'll notice you can see it right here, so we're definitely in there.
Or you could type in pwd and you see, yep, we're still in there.
We could type ls to list the stuff in this directory and
we see there's that hello.rb file.
So to run this, first I'm going to clear the screen here.
To run all ruby programs, we just type in ruby and then the name of the file.
So hello.rb.
When we do, you see a print on the screen.
Hello world!
Very cool.
Congratulation, you've just created your first ruby program.
Very, very simple and it's really just that simple.
Head back over to our sublime text editor and let's play around a little bit.
Let's add one more line here, type in system and then clear.
And then go ahead and save this.
And what this does is that it just clears this screen.
So let's head back over here and
I'm going to hit Enter a few times to kind of clutter up our screen.
Now let's run that file again.
So to run your file you can type in ruby and then hello.rb or
you can just hit the Up arrow key on your keyboard.
Ad that will just paste in the last command so that's kind of handy.
So, let's go ahead and run this. And boom,
you see it clears the screen first and then it prints out a Hello world.
So, that's just kind of a nice thing to do,
I recommend that you have that line at the top of all your ruby code throughout this
course just to make it easier to run and to read stuff from the terminal.
So very, very cool and that's our first review program.
In the future, if you want to add more files to our directory here,
you just right-click and click New File.
You could see it pop ups, and then we just go to File > Save As.
Let's call this secondprogram.rb.
That pops right up, we can close these.
In the future if we want to open them again, we just click on them, very cool.
If we want to delete one, we can right click and delete and it disappears,
very cool.
So we got the tools we need to program.
We've already written a very simple, very basic Hello World program,
and we're ready to go.
But before we move on in the course I should mention,
I'm going to be using a different development environment from here on out.
The thing that I'm going to be using is something called Cloud Nine.
And you can see here it is right here.
And this is just a simple tool that has all of these things that we've
already installed on one screen.
So you see, here's the text editor in the middle.
Here's my files on the left, and here's the terminal down here.
This is just an easier way to teach so that I have everything on the screen.
You actually can't use this program yourself.
Amazon bought this company and recently shut it down, so
it's not available anymore.
So you'll just follow along using the tools we've already set up,
your Sublime Text editor, and you Git Bash terminal.
So you know whenever I write something here,
you'll just obviously write it in your Sublime Text, right here, right?
Same exact code the same exact everything.
The files over here on the left hand side,
it will be the same files over here on your left hand side and Sublime Text.
And whenever I write a command down here in the terminal,
you'll write the exact same command in your Git Bash terminal, so
should be able to follow along, no problem.
Like I said, I just use this so it's easier to teach and
have everything on one screen.
So that's all for this video and the next video will look at comments and errors.