Class: Burlap::Array

Inherits:
Array show all
Defined in:
lib/burlap/array.rb

Instance Method Summary collapse

Instance Method Details

#to_burlapObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/burlap/array.rb', line 4

def to_burlap
  # <list><type>[string</type><length>1</length><string>Some</string></list>
  list_content = [
    Burlap::Node.new(:name => "type", :value => "").to_burlap,
    Burlap::Node.new(:name => "length", :value => self.length.to_s).to_burlap
  ]
  list_content += self.map do |element|
    element.to_burlap
  end
  list_content = list_content.join("")
  Burlap::Node.new(:name => "list", :value => list_content).to_burlap
end