Class: EagleCAD::Geometry::Rectangle

Inherits:
Geometry::Rectangle
  • Object
show all
Defined in:
lib/eaglecad/geometry.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_xml(element) ⇒ Object

Create a EagleCAD::Geometry::Rectangle from an REXML::Element

Parameters:

  • element (Element)

    The REXML::Element to parse



135
136
137
138
139
# 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

Instance Method Details

#to_xmlREXML::Element

Returns:

  • (REXML::Element)


142
143
144
145
146
147
# 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