class Bio::PhyloXML::Date

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').

Attributes

desc[RW]

Free text description of the date.

maximum[R]

Integer. Minimum and maximum of the value.

minimum[R]

Integer. Minimum and maximum of the value.

unit[RW]

String. Units in which value is stored.

value[R]

Integer. Value of the date.

Public Instance Methods

maximum=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 819
def maximum=(str)
  @maximum = str.to_i
end
minimum=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 815
def minimum=(str)
  @minimum = str.to_i
end
to_s() click to toggle source

Returns value + unit, for exampe “7 mya”

# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 828
def to_s
  return "#{value} #{unit}"
end
to_xml() click to toggle source

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

# 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
value=(str) click to toggle source
# File lib/bio/db/phyloxml/phyloxml_elements.rb, line 823
def value= (str)
  @value = str.to_i
end