This category contains 2 posts

A gem to create objects from external APIs

I published a gem to load into objects XML and JSON files provided over external APIs (urls). The gem is called api_object and available to be installed over “gem install api_object”. The gem is very easy to use. subclass your object to be loaded from ActiveApi::ApiObject class Station < ActiveApi::ApiObject end Specify the url to load the … Continue reading

Initialize Objects from a hierarchy of hashes (JSON format) in Ruby

There are some nice little functions to initialize Objects in Ruby from a hash. A good example could be found here. But sometimes, when we read an external API (XML or JSON) and parse the result, we get data which is a set of nested hashes and arrays. Then we want to initialize an object … Continue reading