class EagleCAD::DeviceSet::Device

Attributes

connects[R]
name[RW]
package[RW]
technologies[R]

Public Class Methods

from_xml(element) click to toggle source
# File lib/eaglecad/deviceset.rb, line 25
def self.from_xml(element)
    Device.new(element.attributes['name']).tap do |device|
        device.package = element.attributes['package']

        element.elements.each do |element|
            case element.name
                when 'connects'
                    element.elements.each {|connect| device.connects.push Connect.from_xml(connect) }
                when 'technologies'
                    element.elements.each {|technology| device.technologies.push technology.attributes['name'] }
            end
        end
    end
end
new(name) click to toggle source
# File lib/eaglecad/deviceset.rb, line 40
def initialize(name)
    @connects = []
    @name = name
    @technologies = []
end

Public Instance Methods

to_xml() click to toggle source

Generate XML for the {DeviceSet} element @return [REXML::Element]

# File lib/eaglecad/deviceset.rb, line 48
def to_xml
    REXML::Element.new('device').tap do |element|
        element.add_attributes({'name' => name, 'package' => package})

        connects_element = element.add_element('connects')
        connects.each {|connect| connects_element.add_element connect.to_xml }

        technologies_element = element.add_element('technologies')
        technologies.each {|technology| technologies_element.add_element('technology', {'name' => technology}) }
    end
end