class EagleCAD::Geometry::SMD

Attributes

cream[RW]
name[RW]
rotation[RW]
roundness[RW]
stop[RW]
thermals[RW]

Public Class Methods

from_xml(element) click to toggle source

Create a {SMD} from an {REXML::Element} @param [Element] element The {REXML::Element} to parse

# File lib/eaglecad/geometry.rb, line 155
def self.from_xml(element)
    size = Size[element.attributes['dx'].to_f, element.attributes['dy'].to_f]
    SMD.new(origin:Geometry.point_from(element, 'x', 'y'), size:size).tap do |smd|
        smd.cream = ('no' != element.attributes['cream'])
        smd.name = element.attributes['name']
        smd.rotation = element.attributes['rot']
        smd.roundness = element.attributes['roundness'].to_i
        smd.stop = ('no' != element.attributes['stop'])
        smd.thermals = ('no' != element.attributes['thermals'])
    end
end

Public Instance Methods

to_xml() click to toggle source

@return [REXML::Element]

# File lib/eaglecad/geometry.rb, line 168
def to_xml
    REXML::Element.new('smd').tap do |element|
        element.add_attributes({'name' => name,
                                'x' => Geometry.format(origin.x),
                                'y' => Geometry.format(origin.y),
                                'dx' => Geometry.format(size.width),
                                'dy' => Geometry.format(size.height)})
        element.add_attribute('cream', 'no') unless cream
        element.add_attribute('rot', rotation) if rotation
        element.add_attribute('roundness', Geometry.format(roundness)) unless 0 == roundness
        element.add_attribute('stop', 'no') unless stop
        element.add_attribute('thermals', 'no') unless thermals
    end
end