Class: EagleCAD::DeviceSet::Device
- Inherits:
-
Object
- Object
- EagleCAD::DeviceSet::Device
- Defined in:
- lib/eaglecad/deviceset.rb
Instance Attribute Summary collapse
-
#connects ⇒ Object
readonly
Returns the value of attribute connects.
-
#name ⇒ Object
Returns the value of attribute name.
-
#package ⇒ Object
Returns the value of attribute package.
-
#technologies ⇒ Object
readonly
Returns the value of attribute technologies.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Device
constructor
A new instance of Device.
-
#to_xml ⇒ REXML::Element
Generate XML for the EagleCAD::DeviceSet element.
Constructor Details
#initialize(name) ⇒ Device
Returns a new instance of Device.
40 41 42 43 44 |
# File 'lib/eaglecad/deviceset.rb', line 40 def initialize(name) @connects = [] @name = name @technologies = [] end |
Instance Attribute Details
#connects ⇒ Object (readonly)
Returns the value of attribute connects.
23 24 25 |
# File 'lib/eaglecad/deviceset.rb', line 23 def connects @connects end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/eaglecad/deviceset.rb', line 22 def name @name end |
#package ⇒ Object
Returns the value of attribute package.
22 23 24 |
# File 'lib/eaglecad/deviceset.rb', line 22 def package @package end |
#technologies ⇒ Object (readonly)
Returns the value of attribute technologies.
23 24 25 |
# File 'lib/eaglecad/deviceset.rb', line 23 def technologies @technologies end |
Class Method Details
.from_xml(element) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 |
Instance Method Details
#to_xml ⇒ REXML::Element
Generate XML for the EagleCAD::DeviceSet element
48 49 50 51 52 53 54 55 56 57 58 |
# 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 |