Class: EagleCAD::Geometry::Rectangle
- Inherits:
-
Geometry::Rectangle
- Object
- Geometry::Rectangle
- EagleCAD::Geometry::Rectangle
- Defined in:
- lib/eaglecad/geometry.rb
Class Method Summary collapse
-
.from_xml(element) ⇒ Object
Create a Rectangle from an REXML::Element.
Instance Method Summary collapse
Class Method Details
.from_xml(element) ⇒ Object
Create a EagleCAD::Geometry::Rectangle from an REXML::Element
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_xml ⇒ 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 |