Class: EagleCAD::Board::Signal

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Signal

Returns a new instance of Signal.



96
97
98
99
100
# File 'lib/eaglecad/board.rb', line 96

def initialize(name)
		@contact_references = []
		@name = name
		@vias = []
end

Instance Attribute Details

#air_wires_hiddenObject

Returns the value of attribute air_wires_hidden.



66
67
68
# File 'lib/eaglecad/board.rb', line 66

def air_wires_hidden
  @air_wires_hidden
end

#clearance_classObject

Returns the value of attribute clearance_class.



66
67
68
# File 'lib/eaglecad/board.rb', line 66

def clearance_class
  @clearance_class
end

#contact_referencesObject (readonly)

Returns the value of attribute contact_references.



67
68
69
# File 'lib/eaglecad/board.rb', line 67

def contact_references
  @contact_references
end

#nameObject

Returns the value of attribute name.



66
67
68
# File 'lib/eaglecad/board.rb', line 66

def name
  @name
end

#viasObject (readonly)

Returns the value of attribute vias.



67
68
69
# File 'lib/eaglecad/board.rb', line 67

def vias
  @vias
end

Class Method Details

.from_xml(element) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/eaglecad/board.rb', line 69

def self.from_xml(element)
		self.new(element.attributes['name']).tap do |signal|
 element.attributes.each do |name, value|
			case name
  when 'airwireshidden'
				signal.air_wires_hidden = ('no' != value)
  when 'class'
				signal.clearance_class = value.to_i
  when 'name'	# Ignore; already handled
  else
				raise StandardError, "Unrecognized Signal element '#{element.name}'"
			end
 end

 element.elements.each do |element|
			case element.name
  when 'contactref'
				signal.contact_references.push ContactReference.new element.attributes['element'], element.attributes['pad'], element.attributes['route'], element.attributes['routetag']
  when 'polygon', 'wire'
				signal.push Geometry.from_xml(element)
  when 'via'
				signal.vias.push Via.new Geometry.from_point(element), element.attributes['extent'], element.attributes['drill']
			end
 end
		end
end