Login

Ruby

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Leveraging Ruby

This article is part of series where we build and enhance the "mobile site generation" project. Each installment in this articles series looks at different computer language.

Project Summary
The "mobile site generation" project is a command line utility. The command line utility generates a section of my website which can be viewed on a mobile web browser. Please refer to previous installments of this series for more details.

Why Specifications Matter
This is the third version of my "mobile site generation" project. The first version was written in Java, the second version in Scala, and now, the third version in Ruby.The processes, data structures, data flow and basic logic have remained constant through all 3 versions. These constants are typically recorded in the "system specification". The system specification describes "what" the project does and "how" the project does it. The system specification can be expressed in many different forms (E.G. a formal document, diagrams, even test plans). The point is, the system specification has some value and it exists independent of the computer language used to implement the system.

Ruby
Ruby is the computer language name. "Ruby on Rails" is a application framework. A good portion of "Ruby on Rails" is written with Ruby (the computer language). However, "Ruby" and "Ruby on Rails" are not the same. In this article series, we are looking at computer languages (not application frameworks). Thus, this article is about "Ruby" the computer language (not "Ruby on Rails" the application framework).

Ruby's Elegance
Ruby's syntax and program statements are concise (short). Like Scala, we can use a like break to delimit statements. Ruby delimits functions with a simple "def" and "end". Again, like Scala your Ruby functions (methods) don't require an explicit "return" instruction. The function return the last statement result.

I used a SAX parser and SAX event handler to parse the website's RSS XML document. I used a Ruby Gem (I.E. library) LibXml. As an example of how elegant and concise Ruby is, here is my SAX event handler implementation:

Syndicate content