Skip to content

coderelax/rightmove_blm

 
 

Repository files navigation

Rightmove BLM

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.

Usage

Loading a BLM file

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 of RightmoveBLM::Row objects (use dot notation to access fields, e.g. row.foo to access the "foo" field).

RightmoveBLM::Row also implements #to_h which provides a Hash of the row data.

Example

blm.data.each do |row|
  puts row.address_1
  puts row.to_h
end

Writing BLM data

An 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)

About

Rightmove BLM format processing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 98.8%
  • Makefile 1.2%