Main Content

Easy example - data record to object and object to data record mapping in Ruby

Archive - Originally posted on "The Horse's Mouth" - 2015-11-21 12:59:04 - Graham Ellis

From the Ruby course just finished - an example of an application that reads through a data file, passes comments through unaltered, converts valid data lines into objects which it updates and writes back in place. The whole busisness of mapping data records to objects and objects back to data records is an interesting one; typically, the "forward" mapping might be done in a factory method, and the back mapping within the object's to_s method.

Source code - [here].