class EagleCAD::Geometry::Rectangle

Public Class Methods

from_xml(element) click to toggle source

Create a {Rectangle} from an {REXML::Element} @param [Element] element The {REXML::Element} to parse

# File lib/eaglecad/geometry.rb, line 135
def self.from_xml(element)
    first = Geometry.point_from(element, 'x1', 'y1')
    last = Geometry.point_from(element, 'x2', 'y2')
    self.new(first, last)
end

Public Instance Methods

to_xml() click to toggle source

@return [REXML::Element]

# File lib/eaglecad/geometry.rb, line 142
def to_xml
    REXML::Element.new('rectangle').tap {|element| element.add_attributes({'x1' => Geometry.format(origin.x),
                                                                           'y1' => Geometry.format(origin.y),
                                                                           'x2' => Geometry.format(max.x),
                                                                           'y2' => Geometry.format(max.y)}) }
end