Class: EagleCAD::Geometry::SMD

Inherits:
Geometry::SizedRectangle
  • Object
show all
Defined in:
lib/eaglecad/geometry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#creamObject

Returns the value of attribute cream.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def cream
  @cream
end

#nameObject

Returns the value of attribute name.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def name
  @name
end

#rotationObject

Returns the value of attribute rotation.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def rotation
  @rotation
end

#roundnessObject

Returns the value of attribute roundness.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def roundness
  @roundness
end

#stopObject

Returns the value of attribute stop.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def stop
  @stop
end

#thermalsObject

Returns the value of attribute thermals.



151
152
153
# File 'lib/eaglecad/geometry.rb', line 151

def thermals
  @thermals
end

Class Method Details

.from_xml(element) ⇒ Object

Create a EagleCAD::Geometry::SMD from an REXML::Element

Parameters:

  • element (Element)

    The REXML::Element to parse



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/eaglecad/geometry.rb', line 155

def self.from_xml(element)
		size = Size[element.attributes['dx'].to_f, element.attributes['dy'].to_f]
		SMD.new(origin:Geometry.point_from(element, 'x', 'y'), size:size).tap do |smd|
 smd.cream = ('no' != element.attributes['cream'])
 smd.name = element.attributes['name']
 smd.rotation = element.attributes['rot']
 smd.roundness = element.attributes['roundness'].to_i
 smd.stop = ('no' != element.attributes['stop'])
 smd.thermals = ('no' != element.attributes['thermals'])
		end
end

Instance Method Details

#to_xmlREXML::Element

Returns:

  • (REXML::Element)


168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/eaglecad/geometry.rb', line 168

def to_xml
		REXML::Element.new('smd').tap do |element|
 element.add_attributes({'name' => name,
    'x' => Geometry.format(origin.x),
    'y' => Geometry.format(origin.y),
    'dx' => Geometry.format(size.width),
    'dy' => Geometry.format(size.height)})
 element.add_attribute('cream', 'no') unless cream
 element.add_attribute('rot', rotation) if rotation
 element.add_attribute('roundness', Geometry.format(roundness)) unless 0 == roundness
 element.add_attribute('stop', 'no') unless stop
 element.add_attribute('thermals', 'no') unless thermals
		end
end