advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Sidebar 1. Instructions for Executing launcher.rb in Unix and Windows
Sidebar 2. Why You Add initialize Method When Passing Arguments to 'new' Method
Sidebar 3. A Few Words About Objects, Types, and Behavior
Sidebar 4. The Smarts Behind Launching Logic
Sidebar 5. Dynamic Class Loading
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 2.9/5 | Rate this item | 49 users have rated this item.
 

10 Minutes to Your First Ruby Application

There's no better way to experience the elegance and power of Ruby than to fire up your code editor and start writing Ruby code. Create a small, useful Ruby application, and along the way, you'll learn what makes the language tick. 


advertisement
o you've discovered the grace and power of Ruby and you're ready to explore the subtle but important ideas behind its elegance. Follow this tutorial to create a small, useful Ruby application. As Ruby is primarily an object-oriented language with classes and objects, you can jump right in and create a class to encapsulate behavior. The instructions begin with a simple version of the application, and then expand it. Along the way, you will learn what makes Ruby tick.

The example application will serve two purposes:

  1. Demonstrate some features of Ruby.
  2. Do something useful in the process.

A word on the title: Were you to write this code yourself, assuming some moderate Ruby knowledge, it probably wouldn't take more than 10 minutes. Once you learn how Ruby works and understand what sort of code it enables, you'll find that you can whip up useful utilities in short order. Of course, a walkthrough of such code will take a bit more than 10 minutes if you're new to the language.

What You Need
This tutorial assumes that you already have a current version of Ruby installed, and you have a code editor handy. You don't need a fancy IDE to code in Ruby; Vim, Emacs, and TextMate are great choices. NetBeans and Eclipse work fine as well.

Target Problem: Simplifying File Launching
Ruby is primarily a text-based, command-line-oriented language. Some GUI libraries are available, as well as multiple Web application frameworks, but exploring GUI development with Ruby is beyond the scope this article. The goal here is to write something that works from the command line.

The example task is simplifying file launching. Given a text file (maybe a Ruby source code file), suppose you want to create a way to launch it in some associated application from the command line. And you want to launch it without having to keep track of file types and application associations. Yes, Windows already does this, but your application will have additional features that go beyond this simple behavior.

  Next Page: Version 0: The Launcher Code
advertisement
Page 1: IntroductionPage 4: Writing a Handler Class
Page 2: Version 0: The Launcher CodePage 5: Clean, Expressive Code with Minimal Scaffolding
Page 3: Bulking Up to Version 1 with Dynamic Loading 
Please rate this item (5=best)
 1  2  3  4  5
DevX is a division of Jupitermedia Corporation
© Copyright 2007 Jupitermedia Corporation. All Rights Reserved. Legal Notices
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs