Class: EagleCAD::Sheet::Net

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, clearance_class) ⇒ Net



131
132
133
134
135
# File 'lib/eaglecad/sheet.rb', line 131

def initialize(name, clearance_class)
    @clearance_class = clearance_class
    @name = name
    @segments = []
end

Instance Attribute Details

#clearance_classObject

Returns the value of attribute clearance_class.



122
123
124
# File 'lib/eaglecad/sheet.rb', line 122

def clearance_class
  @clearance_class
end

#nameObject

Returns the value of attribute name.



122
123
124
# File 'lib/eaglecad/sheet.rb', line 122

def name
  @name
end

#segmentsObject (readonly)

Returns the value of attribute segments.



123
124
125
# File 'lib/eaglecad/sheet.rb', line 123

def segments
  @segments
end

Class Method Details

.from_xml(element) ⇒ Object



125
126
127
128
129
# File 'lib/eaglecad/sheet.rb', line 125

def self.from_xml(element)
    Net.new(element.attributes['name'], element.attributes['class'].to_i).tap do |net|
 element.elements.each {|segment| net.segments.push Segment.from_xml(segment) }
    end
end

Instance Method Details

#to_xmlObject



137
138
139
140
141
142
143
144
# File 'lib/eaglecad/sheet.rb', line 137

def to_xml
    REXML::Element.new('net').tap do |element|
 element.add_attribute('name', name)
 element.add_attribute('class', clearance_class) unless 0 == clearance_class

 segments.each {|segment| element.add_element segment.to_xml }
    end
end