Class: Bio::PhyloXML::Date
- Defined in:
- lib/bio/db/phyloxml/phyloxml_elements.rb
Overview
Description
A date associated with a clade/node. Its value can be numerical by using the ‘value’ element and/or free text with the ‘desc’ element’ (e.g. ‘Silurian’). If a numerical value is used, it is recommended to employ the ‘unit’ attribute to indicate the type of the numerical value (e.g. ‘mya’ for ‘million years ago’).
Instance Attribute Summary collapse
-
#desc ⇒ Object
Free text description of the date.
-
#maximum ⇒ Object
Integer.
-
#minimum ⇒ Object
Integer.
-
#unit ⇒ Object
String.
-
#value ⇒ Object
Integer.
Instance Method Summary collapse
-
#to_s ⇒ Object
Returns value + unit, for exampe “7 mya”.
-
#to_xml ⇒ Object
Converts elements to xml representation.
Instance Attribute Details
#desc ⇒ Object
Free text description of the date.
807 808 809 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 807 def desc @desc end |
#maximum ⇒ Object
Integer. Minimum and maximum of the value.
810 811 812 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 810 def maximum @maximum end |
#minimum ⇒ Object
Integer. Minimum and maximum of the value.
810 811 812 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 810 def minimum @minimum end |
#unit ⇒ Object
String. Units in which value is stored.
804 805 806 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 804 def unit @unit end |
#value ⇒ Object
Integer. Value of the date.
813 814 815 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 813 def value @value end |
Instance Method Details
#to_s ⇒ Object
Returns value + unit, for exampe “7 mya”
828 829 830 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 828 def to_s return "#{value} #{unit}" end |
#to_xml ⇒ Object
Converts elements to xml representation. Called by PhyloXML::Writer class.
833 834 835 836 837 838 839 840 841 842 |
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 833 def to_xml date = LibXML::XML::Node.new('date') PhyloXML::Writer.generate_xml(date, self, [ [:attr, 'unit'], [:simple, 'desc', (defined? @desc) ? @desc : nil], [:simple, 'value', (defined? @value) ? @value : nil], [:simple, 'minimum', (defined? @minimum) ? @minimum : nil], [:simple, 'maximum', (defined? @maximum) ? @maximum : nil]]) return date end |