How to save a text file with a Ruby (.rb) file extension

rubyterminaltextedit

I am new to Ruby and am trying to learn from a book. However, I have one problem – it says I should save a file so that it ends with .rb but my Mac only lets me use .rtf so that's what I used. But the next thing I needed to do was open it in Terminal and the command cd /Users/username/ruby didn't work for me. I'm guessing the reason for this is because I didn't use .rb it didn't work.

So my question is: What should I use for writing Ruby in the end of that command, or for saving with the .rb extension?

Best Answer

You could only save as .rtf because the file was rich text. To make it plain text, simply press ⇧ shift-⌘ command-T or go Format > Make Plain Text, then you can save as .rb.

Try not to use TextEdit: there is no syntax highlighting and code completion, not to mention that you have to manually turn off those wrong quotation marks.