class EagleCAD::Clearance

Attributes

drill[RW]
name[RW]
number[RW]
values[R]
width[RW]

Public Class Methods

from_xml(element) click to toggle source
# 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
new(name, number) click to toggle source
# File lib/eaglecad/clearance.rb, line 17
def initialize(name, number)
    @name = name
    @number = number
    @values = []
end

Public Instance Methods

to_xml() click to toggle source

@param [REXML::Element]

# 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