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

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

Parameters:

  • element (REXML::Element)

    The REXML::Element to parse

  • x_name (String) (defaults to: 'x')

    The name of the attribute containing the X coordinate

  • y_name (String) (defaults to: 'y')

    The name of the attribute containing the Y coordinate



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