class EagleCAD::Geometry::Text
Attributes
align[RW]
distance[RW]
font[RW]
layer[RW]
origin[RW]
ratio[RW]
rotation[RW]
size[RW]
text[RW]
Public Class Methods
from_xml(element)
click to toggle source
# 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
new(origin, layer, size, text, options={})
click to toggle source
# File lib/eaglecad/geometry.rb, line 197 def initialize(origin, layer, size, text, options={}) @origin = origin @layer = layer @size = size @text = text @align = options['align'] || 'bottom-left' @distance = options['distance'] || 50 @font = options['font'] || 'proportional' @ratio = options['ratio'] || 8 @rotation = options['rot'] || 'R0' end
Public Instance Methods
to_xml()
click to toggle source
@return [REXML::Element]
# 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