Class: EagleCAD::Geometry::Text
- Inherits:
-
Object
- Object
- EagleCAD::Geometry::Text
- Defined in:
- lib/eaglecad/geometry.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
Returns the value of attribute align.
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#font ⇒ Object
Returns the value of attribute font.
-
#layer ⇒ Object
Returns the value of attribute layer.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#ratio ⇒ Object
Returns the value of attribute ratio.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#size ⇒ Object
Returns the value of attribute size.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(origin, layer, size, text, options = {}) ⇒ Text
constructor
A new instance of Text.
- #to_xml ⇒ REXML::Element
Constructor Details
#initialize(origin, layer, size, text, options = {}) ⇒ Text
Returns a new instance of Text.
197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/eaglecad/geometry.rb', line 197 def initialize(origin, layer, size, text, ={}) @origin = origin @layer = layer @size = size @text = text @align = ['align'] || 'bottom-left' @distance = ['distance'] || 50 @font = ['font'] || 'proportional' @ratio = ['ratio'] || 8 @rotation = ['rot'] || 'R0' end |
Instance Attribute Details
#align ⇒ Object
Returns the value of attribute align.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def align @align end |
#distance ⇒ Object
Returns the value of attribute distance.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def distance @distance end |
#font ⇒ Object
Returns the value of attribute font.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def font @font end |
#layer ⇒ Object
Returns the value of attribute layer.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def layer @layer end |
#origin ⇒ Object
Returns the value of attribute origin.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def origin @origin end |
#ratio ⇒ Object
Returns the value of attribute ratio.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def ratio @ratio end |
#rotation ⇒ Object
Returns the value of attribute rotation.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def rotation @rotation end |
#size ⇒ Object
Returns the value of attribute size.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def size @size end |
#text ⇒ Object
Returns the value of attribute text.
185 186 187 |
# File 'lib/eaglecad/geometry.rb', line 185 def text @text end |
Class Method Details
.from_xml(element) ⇒ Object
187 188 189 190 191 192 193 194 195 |
# File 'lib/eaglecad/geometry.rb', line 187 def self.from_xml(element) Geometry::Text.new(Geometry.point_from(element, 'x', 'y'), element.attributes['layer'], element.attributes['size'].to_f, element.text).tap do |object| object.align = element.attributes['align'] || object.align object.distance = element.attributes['distance'] || object.distance object.font = element.attributes['font'] || object.font object.ratio = element.attributes['ratio'] || object.ratio object.rotation = element.attributes['rot'] || object.rotation end end |
Instance Method Details
#to_xml ⇒ REXML::Element
211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/eaglecad/geometry.rb', line 211 def to_xml REXML::Element.new('text').tap do |element| element.add_attributes({'x' => Geometry.format(origin.x), 'y' => Geometry.format(origin.y), 'layer' => layer, 'size' => Geometry.format(size)}) element.add_attribute('align', align) element.add_attribute('distance', distance) element.add_attribute('font', font) element.add_attribute('ratio', ratio) element.add_attribute('rot', rotation) element.text = text end end |