Class: Tube::LineGroup

Inherits:
Array
  • Object
show all
Defined in:
lib/line_group.rb

Overview

Really just an array with an appropriate #to_xml method.

Instance Method Summary collapse

Instance Method Details

#to_xml(as_string = true) ⇒ Object

:call-seq: line_group.to_xml -> string line_group.to_xml(false) -> rexml_document.

Returns a string of XML representing the object.

<lines>
  contents of the array as xml...
</lines>

Alternately pass false as the only argument to get an instance of REXML::Document.



18
19
20
21
22
23
24
25
# File 'lib/line_group.rb', line 18

def to_xml( as_string=true )
  doc = REXML::Document.new
  root = doc.add_element( "lines" )
  each do |e|
    root.add_element( e.to_xml( false ) )
  end
  if as_string then doc.to_s else doc end
end