Class: EagleCAD::Part
- Inherits:
-
Object
- Object
- EagleCAD::Part
- Defined in:
- lib/eaglecad/part.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
-
#deviceset ⇒ Object
Returns the value of attribute deviceset.
-
#library ⇒ Object
Returns the value of attribute library.
-
#name ⇒ Object
Returns the value of attribute name.
-
#technology ⇒ Object
Returns the value of attribute technology.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, library, deviceset, device) ⇒ Part
constructor
A new instance of Part.
- #to_xml ⇒ Object
Constructor Details
#initialize(name, library, deviceset, device) ⇒ Part
Returns a new instance of Part.
14 15 16 17 18 19 20 |
# File 'lib/eaglecad/part.rb', line 14 def initialize(name, library, deviceset, device) @name = name @library = library @deviceset = deviceset @device = device @technology = '' end |
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def device @device end |
#deviceset ⇒ Object
Returns the value of attribute deviceset.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def deviceset @deviceset end |
#library ⇒ Object
Returns the value of attribute library.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def library @library end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def name @name end |
#technology ⇒ Object
Returns the value of attribute technology.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def technology @technology end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/eaglecad/part.rb', line 5 def value @value end |
Class Method Details
.from_xml(element) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/eaglecad/part.rb', line 7 def self.from_xml(element) Part.new(element.attributes['name'], element.attributes['library'], element.attributes['deviceset'], element.attributes['device']).tap do |part| part.technology = element.attributes['technology'] if element.attributes['technology'] part.value = element.attributes['value'] if element.attributes['value'] end end |
Instance Method Details
#to_xml ⇒ Object
22 23 24 25 26 27 |
# File 'lib/eaglecad/part.rb', line 22 def to_xml REXML::Element.new('part').tap do |element| element.add_attributes({'name' => name, 'library' => library, 'deviceset' => deviceset, 'device' => device, 'technology' => technology}) element.add_attribute('value', value) if value end end |