Class: EagleCAD::Clearance

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, number) ⇒ Clearance

Returns a new instance of Clearance.



17
18
19
20
21
# File 'lib/eaglecad/clearance.rb', line 17

def initialize(name, number)
    @name = name
    @number = number
    @values = []
end

Instance Attribute Details

#drillObject

Returns the value of attribute drill.



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

def drill
  @drill
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#numberObject

Returns the value of attribute number.



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

def number
  @number
end

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/eaglecad/clearance.rb', line 6

def values
  @values
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.from_xml(element) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/eaglecad/clearance.rb', line 8

def self.from_xml(element)
    Clearance.new(element.attributes['name'], element.attributes['number'].to_i).tap do |clearance|
	clearance.width = (element.attributes['width'] || 0).to_f
	clearance.drill = (element.attributes['drill'] || 0).to_f

	element.elements.each {|element| clearance.values.push (element.text || 0).to_f }
    end
end

Instance Method Details

#to_xmlObject

Parameters:

  • (REXML::Element)


24
25
26
27
28
29
# File 'lib/eaglecad/clearance.rb', line 24

def to_xml
    REXML::Element.new('class').tap do |element|
	element.add_attributes({'name' => name, 'number' => number, 'width' => width, 'drill' => drill})
	values.each {|value| element.add_element('clearance', {'class' => number, 'value' => value})}
    end
end