Class: Bio::PhyloXML::Date

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-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

Instance Method Summary collapse

Instance Attribute Details

#descObject

Free text description of the date.



796
797
798
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 796

def desc
  @desc
end

#maximumObject

Integer. Minimum and maximum of the value.



799
800
801
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 799

def maximum
  @maximum
end

#minimumObject

Integer. Minimum and maximum of the value.



799
800
801
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 799

def minimum
  @minimum
end

#unitObject

String. Units in which value is stored.



793
794
795
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 793

def unit
  @unit
end

#valueObject

Integer. Value of the date.



802
803
804
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 802

def value
  @value
end

Instance Method Details

#to_sObject

Returns value + unit, for exampe “7 mya”



817
818
819
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 817

def to_s
  return "#{value} #{unit}"
end

#to_xmlObject

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



822
823
824
825
826
827
828
829
830
831
# File 'lib/bio-phyloxml/phyloxml_elements.rb', line 822

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