class EagleCAD::Sheet::Label

Attributes

cross_reference[RW]
font[RW]
layer_number[RW]
origin[RW]
ratio[RW]
rotation[RW]
size[RW]

Public Class Methods

from_xml(element) click to toggle source
# File lib/eaglecad/sheet.rb, line 87
def self.from_xml(element)
    Label.new(Geometry.point_from(element), element.attributes['size'].to_f, element.attributes['layer'].to_i).tap do |label|
        element.attributes.each do |name, value|
            case name
                when 'font'          then label.font = value.to_sym
                when 'ratio'    then label.ratio = value.to_i
                when 'rot'           then label.rotation = value
                when 'xref'          then label.cross_reference = ('no' != value)
            end
        end
    end
end
new(origin, size, layer_number) click to toggle source
# File lib/eaglecad/sheet.rb, line 100
def initialize(origin, size, layer_number)
    @origin = origin
    @size = size
    @layer_number = layer_number
    @font = :proportional
    @ratio = 8
    @rotation = 'R0'
    @cross_reference = false
end

Public Instance Methods

to_xml() click to toggle source
# File lib/eaglecad/sheet.rb, line 110
def to_xml
    REXML::Element.new('label').tap do |element|
        element.add_attributes({'x' => origin.x, 'y' => origin.y, 'layer' => layer_number ,'size' => size})
        element.add_attribute('font', font)
        element.add_attribute('ratio', ratio) unless 8 == ratio
        element.add_attribute('rot', rotation)
        element.add_attribute('xref', cross_reference) if cross_reference
    end
end