Class | Bio::PhyloXML::Property
In: | lib/bio/db/phyloxml/phyloxml_elements.rb
Parent: | Object

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>

### Methods

applies_to= datatype= to_xml

### 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)

[Source]

         # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 948
    948:       def applies_to=(str)
    949:         unless ['phylogeny','clade','node','annotation','parent_branch','other'].include?(str)
    950:           puts "Warning: #{str} is not in the list of allowed values."
    951:         end
    952:         @applies_to = str
    953:       end

datatype=(str)

[Source]

         # File lib/bio/db/phyloxml/phyloxml_elements.rb, line 933
    933:       def datatype=(str)
    934:          #@todo add unit test or maybe remove, if assume that xml is valid.
    935:         unless ['xsd:string','xsd:boolean','xsd:decimal','xsd:float','xsd:double',
    936:             'xsd:duration','xsd:dateTime','xsd:time','xsd:date','xsd:gYearMonth',
    937:             'xsd:gYear','xsd:gMonthDay','xsd:gDay','xsd:gMonth','xsd:hexBinary',
    938:             'xsd:base64Binary','xsd:anyURI','xsd:normalizedString','xsd:token',
    939:             'xsd:integer','xsd:nonPositiveInteger','xsd:negativeInteger',
    940:             'xsd:long','xsd:int','xsd:short','xsd:byte','xsd:nonNegativeInteger',
    941:             'xsd:unsignedLong','xsd:unsignedInt','xsd:unsignedShort',
    942:             'xsd:unsignedByte','xsd:positiveInteger'].include?(str)
    943:           raise "Warning: #{str} is not in the list of allowed values."
    944:         end
    945:         @datatype = str
    946:       end

to_xml()

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

[Source]

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

[Validate]