Class: EagleCAD::Sheet::Bus

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) ⇒ Bus

Returns a new instance of Bus.



31
32
33
34
# File 'lib/eaglecad/sheet.rb', line 31

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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/eaglecad/sheet.rb', line 22

def name
  @name
end

#segmentsObject (readonly)

Returns the value of attribute segments.



23
24
25
# File 'lib/eaglecad/sheet.rb', line 23

def segments
  @segments
end

Class Method Details

.from_xml(element) ⇒ Object



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

def self.from_xml(element)
		Bus.new(element.attributes['name']).tap do |bus|
 element.elements.each {|segment| bus.segments.push Segment.from_xml(segment) }
		end
end

Instance Method Details

#to_xmlObject



36
37
38
39
40
41
# File 'lib/eaglecad/sheet.rb', line 36

def to_xml
		REXML::Element.new('bus').tap do |element|
 element.add_attribute 'name', name
 segments.each {|segment| element.add_element segment.to_xml }
		end
end