Module: EagleCAD::Geometry
- Defined in:
- lib/eaglecad/geometry.rb
Defined Under Namespace
Classes: Circle, Hole, Line, Pad, Pin, Polygon, Rectangle, SMD, Text
Constant Summary collapse
- Point =
::Geometry::Point
Class Method Summary collapse
- .format(value) ⇒ Object
- .from_xml(element) ⇒ Object
-
.point_from(element, x_name = 'x', y_name = 'y') ⇒ Object
Create a Point from the given REXML::Element using the passed attribute names.
Class Method Details
.format(value) ⇒ Object
255 256 257 |
# File 'lib/eaglecad/geometry.rb', line 255 def self.format(value) "%g" % value end |
.from_xml(element) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/eaglecad/geometry.rb', line 224 def self.from_xml(element) case element.name when 'circle' Geometry::Circle.from_xml(element) when 'hole' Geometry::Hole.from_xml(element) when 'pad' Geometry::Pad.from_xml(element) when 'pin' Geometry::Pin.from_xml(element) when 'polygon' Geometry::Polygon.from_xml(element) when 'rectangle' Geometry::Rectangle.from_xml(element) when 'smd' Geometry::SMD.from_xml(element) when 'text' Geometry::Text.from_xml(element) when 'wire' Geometry::Line.from_xml(element) end end |
.point_from(element, x_name = 'x', y_name = 'y') ⇒ Object
Create a Point from the given REXML::Element using the passed attribute names
251 252 253 |
# File 'lib/eaglecad/geometry.rb', line 251 def self.point_from(element, x_name='x', y_name='y') Point[element.attributes[x_name].to_f, element.attributes[y_name].to_f] end |