Running Ruby On Your Own Machine

TODO

  1. Play around with irb

  2. Create Workspace/scratch folder

  3. Setup and configure your code editor (vscode)

  4. Write and run a ruby program on your machine

Terminal

open your terminal

Ruby

Ruby comes preinstalled on macOS

ruby --version or ruby -v to check version

This is your system ruby. You'll need to install different versions when developing rails applications. We'll get into this later.

Make sure you are using the correct version in Ruby Docs

Interactive Ruby (irb)

type in irb

play around with ruby

type exit to exit irb shell

Create scratch/ Folder

Enter open . in terminal window to open Finder

Create Workspace/scratch/ folder

We can keep experimental ruby scripts in scratch/

Setup vscode

vscode is a code editor that works well with ruby, rails, and pretty much any language

  1. Open vscode

  2. File -> Open Folder... -> (click Workspace/scratch/ folder)

Create And Run Ruby File

Create hello.rb file in scratch/

Open hello.rb in vscode

  1. ⌘ + p to open vscode file search
  2. type in filename hello.rb

create program that asks for name and says hello

print 'What is your name? '
name = gets.chomp
puts "Hello #{name}"

Enter ruby hello.rb in the terminal

Download Treehouse Workspace

Click File, Download Workspace

Resources

vscode

install vscode
Ruby Extension
HTML CSS Support Extension
GitLens Extension

Ruby Docs

Ruby Docs

Unix

Commands Cheatsheet

1337 Hacker

Install xcode command line tools xcode-select --install

Install multiple Ruby versions with rbenv

command + space (open spotlight search)

search 'terminal', press `enter`

root path ~

we should be in vscode scratch folder