Class: PolyrexBuilder
- Inherits:
-
Object
- Object
- PolyrexBuilder
- Defined in:
- lib/polyrex-builder.rb
Instance Method Summary collapse
-
#initialize(rows = [], parents: [], summary: {}, rootname: 'items') ⇒ PolyrexBuilder
constructor
A new instance of PolyrexBuilder.
- #to_a ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(rows = [], parents: [], summary: {}, rootname: 'items') ⇒ PolyrexBuilder
Returns a new instance of PolyrexBuilder.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/polyrex-builder.rb', line 13 def initialize(rows=[], parents: [], summary: {}, rootname: 'items') records = rows.map {|x| pxify(x, parents) } summary.merge!({recordx_type: 'polyrex'}) h = {rootname.to_sym => {summary: summary, records: records }} @a = RexleBuilder.new(h).to_a[3] end |
Instance Method Details
#to_a ⇒ Object
24 25 26 |
# File 'lib/polyrex-builder.rb', line 24 def to_a() @a end |
#to_xml ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/polyrex-builder.rb', line 28 def to_xml() doc = Rexle.new(@a) schema = PolyrexSchema.new.parse(doc.root.xml).to_schema doc.root.element('summary').add Rexle::Element.new('schema').add_text(schema) doc.xml pretty: true end |