Class: Bio::PhyloXML::Taxonomy
- Defined in:
- lib/bio/db/phyloxml/phyloxml_elements.rb
Overview
Taxonomy class
Instance Attribute Summary collapse
-
#id_source ⇒ Object
Used to link other elements to a taxonomy (on the xml-level).
-
#other ⇒ Object
Array of Other objects.
-
#taxonomy_id ⇒ Object
String.
-
#uri ⇒ Object
Uri object.
Attributes inherited from Taxonomy
#authority, #code, #common_names, #rank, #scientific_name, #synonyms
Instance Method Summary collapse
-
#initialize ⇒ Taxonomy
constructor
A new instance of Taxonomy.
-
#to_xml ⇒ Object
Converts elements to xml representation.
Constructor Details
#initialize ⇒ Taxonomy
Returns a new instance of Taxonomy.
85 86 87 88 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 85 def initialize super @other = [] end |
Instance Attribute Details
#id_source ⇒ Object
Used to link other elements to a taxonomy (on the xml-level)
77 78 79 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 77 def id_source @id_source end |
#other ⇒ Object
Array of Other objects. Used to save additional information from other than PhyloXML namspace.
83 84 85 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 83 def other @other end |
#taxonomy_id ⇒ Object
String. Unique identifier of a taxon.
75 76 77 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 75 def taxonomy_id @taxonomy_id end |
#uri ⇒ Object
Uri object
79 80 81 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 79 def uri @uri end |
Instance Method Details
#to_xml ⇒ Object
Converts elements to xml representation. Called by PhyloXML::Writer class.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 91 def to_xml taxonomy = LibXML::XML::Node.new('taxonomy') taxonomy["type"] = @type if (defined? @type) && @type taxonomy["id_source"] = @id_source if (defined? @id_source) && @id_source PhyloXML::Writer.generate_xml(taxonomy, self, [[:complex, 'id', (defined? @taxonomy_id) ? @taxonomy_id : nil], [:pattern, 'code', (defined? @code) ? @code : nil, Regexp.new("^[a-zA-Z0-9_]{2,10}$")], [:simple, 'scientific_name', (defined? @scientific_name) ? @scientific_name : nil], [:simple, 'authority', (defined? @authority) ? @authority : nil], [:simplearr, 'common_name', (defined? @common_names) ? @common_names : nil], [:simplearr, 'synonym', (defined? @synonyms) ? @synonyms : nil], [:simple, 'rank', (defined? @rank) ? @rank : nil], [:complex, 'uri',(defined? @uri) ? @uri : nil]]) #@todo anything else return taxonomy end |