Introducing the Polyrex-builder gem
Usage:
require 'polyrex-builder'
r = [
[{name: 'buzz'},
[
[{string: 'hpx'},
[
[{line: '12', command: 'pwd'}],
[{line: '13', command: 'format'}]
]
]
]
]
]
pb = PolyrexBuilder.new(r, parents: %i(entry extension instruction))
puts pb.to_xml
The Polyrex-builder gem accepts a nested array of Hash objects, each represent a summary record. It then generates the XML or an array object (for parsing by the Rexle object) representing a Polyrex document.
Output:
<?xml version='1.0' encoding='UTF-8'?>
<root>
<records>
<entry>
<summary>
<name>buzz</name>
</summary>
<records>
<extension>
<summary>
<string>hpx</string>
</summary>
<records>
<instruction>
<summary>
<line>12</line>
<command>pwd</command>
</summary>
</instruction>
<instruction>
<summary>
<line>13</line>
<command>format</command>
</summary>
</instruction>
</records>
</extension>
</records>
</entry>
</records>
</root>
Resources
- polyrex-builder https://rubygems.org/gems/polyrex-builder
polyrexbuilder gem polyrex builder records