Class: EagleCAD::Geometry::SMD
- Inherits:
-
Geometry::SizedRectangle
- Object
- Geometry::SizedRectangle
- EagleCAD::Geometry::SMD
- Defined in:
- lib/eaglecad/geometry.rb
Instance Attribute Summary collapse
-
#cream ⇒ Object
Returns the value of attribute cream.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#roundness ⇒ Object
Returns the value of attribute roundness.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#thermals ⇒ Object
Returns the value of attribute thermals.
Class Method Summary collapse
-
.from_xml(element) ⇒ Object
Create a SMD from an REXML::Element.
Instance Method Summary collapse
Instance Attribute Details
#cream ⇒ Object
Returns the value of attribute cream.
151 152 153 |
# File 'lib/eaglecad/geometry.rb', line 151 def cream @cream end |
#name ⇒ Object
Returns the value of attribute name.
151 152 153 |
# File 'lib/eaglecad/geometry.rb', line 151 def name @name end |
#rotation ⇒ Object
Returns the value of attribute rotation.
151 152 153 |
# File 'lib/eaglecad/geometry.rb', line 151 def rotation @rotation end |
#roundness ⇒ Object
Returns the value of attribute roundness.
151 152 153 |
# File 'lib/eaglecad/geometry.rb', line 151 def roundness @roundness end |
#stop ⇒ Object
Returns the value of attribute stop.
151 152 153 |
# File 'lib/eaglecad/geometry.rb', line 151 def stop @stop end |
#thermals ⇒ Object
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
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_xml ⇒ 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 |