Ruby Tutorial 5 – Creating a Script

In this video, I show you how to use TextEdit and Terminal in order to create a Ruby program which runs independently of the Ruby console (irb). In the future, we will be able to use this to create larger Ruby programs that interact directly with the user through Terminal.


macheads101 says:

try putting the following at the end of your script:

loop do

jeffscomedystudios says:

Wait I have a question. I ran a file doing ruby and then dragging the file into terminal. However, all it did was say start and then done. It did not create the 2 folders it was supposed to so can you please help?

jeffscomedystudios says:

Dude you do not know how helpful this is I am a newbie and this is extremely helpful. THANKS!

The X Stanmarshk says:

macruby is a cool ruby GUI to install in Xcode

1MRSomeguy says:

hackety hack
cool app for basic ruby.
I still appreciate the vids

Gerber Heinrich says:


nice video. Do you have an email adress, where I can reach you?

losthexteria says:

Quick Question: I have a windows and have been using ruby interactive instead of terminal, and it does exactly what you have been doing, however i don’t know a windows equivalent to text edit. Any Help?

HistoriansVivandGem says:

Once I ran the file in the terminal, I was able to see what I have created, but once I have pressed enter, I see the response, but the terminal itself closes out. Is there something I am missing here? I do appreciate it a lot and your videos have worked tremendously.

macheads101 says:

I assume that you are referring to your own ruby program rather than the code I showed in this video, since there were no “2 folders” in this video. I can help you, but I will need you to send me the ruby code in a personal message.

Nishant Arora says:

Awesome videos man! U have no idea how much u helped! Keep rockin!

Scarr TV says:

I can’t do that like I’m on OS X 10.10.13 2015! but i can’t save it like that its different and i can’t get that font or whatever your using how can i fix this?

OscarDoesProgramming says:

You know I am only 12 and I am a little bored with what you are doing. I am making my own programs from scratch and its really fun. Heres something I made that might impress you:

puts “Enter your name.”
name1 = gets.strip
puts “Enter your age.”
age1 = gets.to_i

puts “Enter your best friends name.”
name2 = gets.strip
puts “Enter #{name2}’s age.”
age2 = gets.to_i

if age1 > age2
  puts “#{name1} is older than #{name2}!”
elsif age1 < age2   puts “#{name2} is older than #{name1}!” else   puts “#{name1} and #{name2} are the same age!” end This is what I made. It takes you name and age and then your friends name and age and tell you which one is bigger. Another one: def print_line(i)   i.times do     print “*”   end   puts “” end print_line(40) puts “Enter a number under 10” i = gets.to_i i.times do   print_line(i) end Takes your number and makes it into a square! Please reply and tell me what you think.

macheads101 says:

I would recommend Notepad

letmewatchthetubez says:

I’m having trouble getting the drag and drop method to run the test.rb. When I drag the file in and hit Enter, it gives me the following error:

SyntaxError: (irb):2: syntax error, unexpected $undefined
ruby C:Ruby200binrubyprogramstest.rb

I’m trying to do this in a Windows 7 VM. I’m not sure if that makes a difference. Also, if I just double click the script after saving it as test.rb, it opens in it’s own shell and works just fine.

Any thoughts?

Melodie ThuThuy Nguyen says:

Very easy to follow, thanks

Alan Brucke says:

please keep these coming, I’ve just started learning ruby and these have helped a ton. very clear and understandable. thanks!

Devontrae Walls says:

If you’d prefer to have an integer rather than a float, try number1.to_i as the to_i method returns an integer.

Thanks for the tutorials man, I’m learning a lot!

Write a comment


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion HatsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   VapesHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours