Class: EagleCAD::Sheet
- Inherits:
-
Object
- Object
- EagleCAD::Sheet
- Defined in:
- lib/eaglecad/sheet.rb
Defined Under Namespace
Classes: Bus, Instance, Label, Net, PinReference, Segment
Instance Attribute Summary collapse
-
#busses ⇒ Object
readonly
Returns the value of attribute busses.
-
#description ⇒ Object
Returns the value of attribute description.
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#nets ⇒ Object
readonly
Returns the value of attribute nets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Sheet
constructor
A new instance of Sheet.
- #push(arg) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize ⇒ Sheet
Returns a new instance of Sheet.
220 221 222 223 224 225 |
# File 'lib/eaglecad/sheet.rb', line 220 def initialize @busses = [] @instances = [] @nets = [] @parts = [] end |
Instance Attribute Details
#busses ⇒ Object (readonly)
Returns the value of attribute busses.
7 8 9 |
# File 'lib/eaglecad/sheet.rb', line 7 def busses @busses end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/eaglecad/sheet.rb', line 6 def description @description end |
#instances ⇒ Object (readonly)
Returns the value of attribute instances.
7 8 9 |
# File 'lib/eaglecad/sheet.rb', line 7 def instances @instances end |
#nets ⇒ Object (readonly)
Returns the value of attribute nets.
7 8 9 |
# File 'lib/eaglecad/sheet.rb', line 7 def nets @nets end |
Class Method Details
.from_xml(element) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/eaglecad/sheet.rb', line 200 def self.from_xml(element) Sheet.new.tap do |sheet| element.elements.each do |element| case element.name when 'busses' element.elements.each {|bus| sheet.push Bus.from_xml(bus) } when 'description' sheet.description = element.text when 'instances' element.elements.each {|instance| sheet.push Instance.from_xml(instance) } when 'nets' element.elements.each {|part| sheet.push Net.from_xml(part) } when 'plain' #Ignore else raise StandardError, "Unrecognized Sheet element '#{element.name}'" end end end end |
Instance Method Details
#push(arg) ⇒ Object
Add the passed EagleCAD::Sheet element to the EagleCAD::Sheet
228 229 230 231 232 233 234 235 236 |
# File 'lib/eaglecad/sheet.rb', line 228 def push(arg) case arg when Bus then busses.push arg when Instance then instances.push arg when Net then nets.push arg else raise ArgumentError, "Unrecognized object '#{arg.class}'" end end |
#to_xml ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/eaglecad/sheet.rb', line 238 def to_xml REXML::Element.new('sheet').tap do |element| element.add_element('description').text = description element.add_element('instances').tap do |instances_element| instances.each {|instance| instances_element.add_element instance.to_xml } end element.add_element('busses').tap do |busses_element| busses.each {|bus| busses_element.add_element bus.to_xml } end element.add_element('nets').tap do |nets_element| nets.each {|net| nets_element.add_element net.to_xml } end end end |