Class: Bio::PhyloXML::Other

Inherits:
Object show all
Defined in:
lib/bio/db/phyloxml/phyloxml_elements.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOther

Returns a new instance of Other.



1151
1152
1153
1154
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1151

def initialize
  @children = []
  @attributes = Hash.new
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



1149
1150
1151
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1149

def attributes
  @attributes
end

#childrenObject

Returns the value of attribute children.



1149
1150
1151
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1149

def children
  @children
end

#element_nameObject

Returns the value of attribute element_name.



1149
1150
1151
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1149

def element_name
  @element_name
end

#valueObject

Returns the value of attribute value.



1149
1150
1151
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1149

def value
  @value
end

Instance Method Details

#to_xmlObject

Converts elements to xml representation. Called by PhyloXML::Writer class.



1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 1157

def to_xml
  o = LibXML::XML::Node.new(@element_name)
  @attributes.each do |key, value|
    o[key] = value
  end
  o << value if value != nil
  children.each do |child_node|
    o << child_node.to_xml
  end
  return o
end