Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Ruby Programming
Previous Page Home Next Page

Editor Support

Ruby is designed to read a program in one pass; this means you can pipe an entire program to Ruby's standard input and it will work just fine.

We can take advantage of this feature to run Ruby code from inside an editor. In Emacs, for instance, you can select a region of Ruby text and use the command Meta-| to execute Ruby. The Ruby interpreter will use the selected region as standard input and output will go to a buffer named ``*Shell Command Output*.'' This feature has come in quite handy for us while writing this book---just select a few lines of Ruby in the middle of a paragraph and try it out!

You can do something similar in the vi editor using ``:!ruby'' which replaces the program text with its output, or ``:w[visible space]!ruby'', which displays the output without affecting the buffer. Other editors have similar features.

While we are on the subject, this would probably be a good place to mention that there is a Ruby mode for Emacs included in the distribution as misc/ruby-mode.el. There are also several syntax-highlighting modules for vim (an enhanced version of the vi editor), jed, and other editors available on the net as well. Check the Ruby FAQ for current locations and availability.
Ruby Programming
Previous Page Home Next Page

 
 
  Published under the terms of the Open Publication License Design by Interspire