class EagleCAD::DeviceSet
Constants
- Connect
- Gate
Attributes
description[RW]
devices[R]
gates[R]
name[RW]
prefix[RW]
uservalue[RW]
Public Class Methods
from_xml(element)
click to toggle source
Create a new {DeviceSet} from an {REXML::Element} @param [Element] element The {REXML::Element} to parse
# File lib/eaglecad/deviceset.rb, line 74 def self.from_xml(element) DeviceSet.new(element.attributes['name']).tap do |deviceset| deviceset.prefix = element.attributes['prefix'] deviceset.uservalue = ('yes' == element.attributes['uservalue']) element.elements.each do |element| case element.name when 'devices' element.elements.each {|device| deviceset.devices.push Device.from_xml(device) } when 'description' deviceset.description = element.text when 'gates' element.elements.each {|gate| deviceset.gates.push Gate.from_xml(gate) } end end end end
new(name)
click to toggle source
# File lib/eaglecad/deviceset.rb, line 92 def initialize(name) @devices = [] @gates = [] @name = name 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 100 def to_xml REXML::Element.new('deviceset').tap do |element| element.add_attributes({'name' => name, 'prefix' => prefix, 'uservalue' => (uservalue ? 'yes' : 'no')}) element.add_element('description').text = description gates_element = element.add_element('gates') gates.each {|gate| gates_element.add_element gate.to_xml } devices_element = element.add_element('devices') devices.each {|device| devices_element.add_element device.to_xml } end end