Class: Bio::PhyloXML::Polygon

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



483
484
485
# File 'lib/bio/phyloxml/elements.rb', line 483

def initialize
  @points = []
end

Instance Attribute Details

#pointsObject

Array of Point objects.



481
482
483
# File 'lib/bio/phyloxml/elements.rb', line 481

def points
  @points
end

Instance Method Details

#to_xmlObject

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



489
490
491
492
493
494
495
496
497
# File 'lib/bio/phyloxml/elements.rb', line 489

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