Class: EagleCAD::Part

Inherits:
Object
  • Object
show all
Defined in:
lib/eaglecad/part.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#deviceObject

Returns the value of attribute device.



5
6
7
# File 'lib/eaglecad/part.rb', line 5

def device
  @device
end

#devicesetObject

Returns the value of attribute deviceset.



5
6
7
# File 'lib/eaglecad/part.rb', line 5

def deviceset
  @deviceset
end

#libraryObject

Returns the value of attribute library.



5
6
7
# File 'lib/eaglecad/part.rb', line 5

def library
  @library
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/eaglecad/part.rb', line 5

def name
  @name
end

#technologyObject

Returns the value of attribute technology.



5
6
7
# File 'lib/eaglecad/part.rb', line 5

def technology
  @technology
end

#valueObject

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_xmlObject



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