Class: EagleCAD::Geometry::Pad

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#diameterObject

Returns the value of attribute diameter

Returns:

  • (Object)

    the current value of diameter



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def diameter
  @diameter
end

#drillObject

Returns the value of attribute drill

Returns:

  • (Object)

    the current value of drill



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def drill
  @drill
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def name
  @name
end

#originObject

Returns the value of attribute origin

Returns:

  • (Object)

    the current value of origin



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def origin
  @origin
end

#rotationObject

Returns the value of attribute rotation

Returns:

  • (Object)

    the current value of rotation



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def rotation
  @rotation
end

#shapeObject

Returns the value of attribute shape

Returns:

  • (Object)

    the current value of shape



66
67
68
# File 'lib/eaglecad/geometry.rb', line 66

def shape
  @shape
end

Class Method Details

.from_xml(element) ⇒ Object



67
68
69
70
# File 'lib/eaglecad/geometry.rb', line 67

def self.from_xml(element)
		origin = Geometry.point_from(element, 'x', 'y')
		Geometry::Pad.new(element.attributes['diameter'], element.attributes['drill'], element.attributes['name'], origin, element.attributes['rot'], element.attributes['shape'])
end

Instance Method Details

#to_xmlREXML::Element

Returns:

  • (REXML::Element)


73
74
75
76
77
78
# File 'lib/eaglecad/geometry.rb', line 73

def to_xml
		REXML::Element.new('pad').tap do |element|
 element.add_attributes({'name' => name, 'x' => Geometry.format(origin.x), 'y' => Geometry.format(origin.y), 'diameter' => diameter, 'drill' => drill, 'shape' => shape})
 element.add_attribute('rot', rotation) unless 'R0' == rotation
		end
end