You are here

Ruby

XML Parser: Rendering the Item in Ruby

The first language to be used for XML parsing is Ruby. Ruby appears to have three main XML libraries: REXML, Hpricot, and libxml-ruby. As time allows, each will be tested.

Before starting the testing, several things need to be done. First, there needs to be a representation of the Item class in Ruby. From the pseudocode initially shown in the problem statement, I derive the Ruby representation of the Item class and its helper classes.

Since no limitations have been set for accessing or modifying the object's data, all fields are implemented with attr_accessor. Unfortunately, since attr_accessor does not have the ability to set default values, the variable initialization needs to be done in the constructor.

One notable difference between the pseudocode and the Ruby version is the casing. While the pseudocode uses "camel case" variable names as standard for Java, the Ruby version uses "underscore" variable names as per the conventions of the community. This creates small differences like critRating vs. crit_rating. There is an ongoing debate as to which is easier to read.

This represents the bare minimum thus far needed to implement the Item object. When discussing testing, other methods will be added to the Item class and helper classes.

Pages

Subscribe to RSS - Ruby