A simple parser for the Rightmove .blm Bulk Load Mass file format.
Originally forked from the BLM gem by Robert May.
This library is not affiliated with or endorsed by Rightmove Plc in any way.
Load a BLM file by passing the source parameter to RightmoveBLM::Document.new:
blm = RightmoveBLM::Document.new(source: File.read('example_data.blm'))The returned RightmoveBLM::Document instance implements:
#header- the header containing information about the document's structure.#definition- the field list contained in the document.#data- an array ofRightmoveBLM::Rowobjects (use dot notation to access fields, e.g.row.footo access the "foo" field).
RightmoveBLM::Row also implements #to_h which provides a Hash of the row data.
blm.data.each do |row|
puts row.address_1
puts row.to_h
endAn array of hashes can be converted to a RightmoveBLM::Document object which can then be used to create an output string by calling #to_blm.
The keys from the first hash in the provided array are used to provide the field definition. All hashes must contain the same keys.
document = RightmoveBLM::Document.from_array_of_hashes([{ field1: 'foo', field2: 'bar' }, { field1: 'baz', field2: 'foobar' }])
File.write('my_data.blm', document.to_blm)