Class: Bio::PhyloXML::Polygon

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/phyloxml/phyloxml_elements.rb

Overview

Description

A polygon defined by a list of Points objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolygon

Returns a new instance of Polygon.



500
501
502
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 500

def initialize
  @points = []
end

Instance Attribute Details

#pointsObject

Array of Point objects.



498
499
500
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 498

def points
  @points
end

Instance Method Details

#to_xmlObject

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



506
507
508
509
510
511
512
513
514
# File 'lib/bio/db/phyloxml/phyloxml_elements.rb', line 506

def to_xml
  if @points.length > 2          
    pol = LibXML::XML::Node.new('polygon')
    @points.each do |p|
      pol << p.to_xml
    end
    return pol
  end
end