class Bio::PhyloXML::Property

Property allows for typed and referenced properties from external resources to be attached to ‘Phylogeny’, ‘Clade’, and ‘Annotation’. The value of a property is its mixed (free text) content. Attribute ‘datatype’ indicates the type of a property and is limited to xsd-datatypes (e.g. ‘xsd:string’, ‘xsd:boolean’, ‘xsd:integer’, ‘xsd:decimal’, ‘xsd:float’, ‘xsd:double’, ‘xsd:date’, ‘xsd:anyURI’). Attribute ‘applies_to’ indicates the item to which a property applies to (e.g. ‘node’ for the parent node of a clade, ‘parent_branch’ for the parent branch of a clade). Attribute ‘id_ref’ allows to attached a property specifically to one element (on the xml-level). Optional attribute ‘unit’ is used to indicate the unit of the property. An example: <property datatype=“xsd:integer” ref=“NOAA:depth” applies_to=“clade” unit=“METRIC:m”> 200 </property>

Attributes

applies_to[R]

String

datatype[R]

String

id_ref[RW]

String

ref[RW]

String

unit[RW]

String

value[RW]

String

Public Instance Methods

applies_to=(str) click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
950 def applies_to=(str)
951   unless ['phylogeny','clade','node','annotation','parent_branch','other'].include?(str)
952     puts "Warning: #{str} is not in the list of allowed values."
953   end
954   @applies_to = str
955 end
datatype=(str) click to toggle source
    # File lib/bio-phyloxml/phyloxml_elements.rb
935 def datatype=(str)
936    #@todo add unit test or maybe remove, if assume that xml is valid.
937   unless ['xsd:string','xsd:boolean','xsd:decimal','xsd:float','xsd:double',
938       'xsd:duration','xsd:dateTime','xsd:time','xsd:date','xsd:gYearMonth',
939       'xsd:gYear','xsd:gMonthDay','xsd:gDay','xsd:gMonth','xsd:hexBinary',
940       'xsd:base64Binary','xsd:anyURI','xsd:normalizedString','xsd:token',
941       'xsd:integer','xsd:nonPositiveInteger','xsd:negativeInteger',
942       'xsd:long','xsd:int','xsd:short','xsd:byte','xsd:nonNegativeInteger',
943       'xsd:unsignedLong','xsd:unsignedInt','xsd:unsignedShort',
944       'xsd:unsignedByte','xsd:positiveInteger'].include?(str)
945     raise "Warning: #{str} is not in the list of allowed values."
946   end
947   @datatype = str
948 end
to_xml() click to toggle source

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

    # File lib/bio-phyloxml/phyloxml_elements.rb
958 def to_xml
959   #@todo  write unit test for this
960   raise "ref is an required element of property"  if @ref.nil?
961   raise "datatype is an required element of property" if @datatype.nil?
962   raise "applies_to is an required element of property" if @applies_to.nil?
963 
964   property = LibXML::XML::Node.new('property')
965   Writer.generate_xml(property, self, [
966       [:attr, 'ref'],
967       [:attr, 'unit'],
968       [:attr, 'datatype'],
969       [:attr, 'applies_to'],
970       [:attr, 'id_ref']])
971 
972   property << @value if @value != nil
973   return property
974 end