class EagleCAD::Geometry::Line

Attributes

cap[RW]
curve[RW]
line_width[RW]

Public Class Methods

from_xml(element) click to toggle source

Create a {Line} from an {REXML::Element} @param [Element] element The {REXML::Element} to parse

# File lib/eaglecad/geometry.rb, line 45
def self.from_xml(element)
self.new(from:Geometry.point_from(element, 'x1', 'y1'), to:Geometry::point_from(element, 'x2', 'y2'), line_width:element.attributes['width'].to_f, cap: element.attributes['cap'], curve: element.attributes['curve'].to_f)
end
new(options={}) click to toggle source
Calls superclass method
# File lib/eaglecad/geometry.rb, line 49
def initialize(options={})
    @cap = options.delete :cap
    @curve = options.delete :curve
    @line_width = options.delete(:line_width)
    super options[:from], options[:to]
end

Public Instance Methods

to_xml() click to toggle source

@return [REXML::Element]

# File lib/eaglecad/geometry.rb, line 57
def to_xml
    REXML::Element.new('wire').tap do |element|
        element.add_attributes({'x1' => Geometry.format(first.x), 'y1' => Geometry.format(first.y), 'x2' => Geometry.format(last.x), 'y2' => Geometry.format(last.y), 'width' => line_width})
        element.add_attribute('cap', cap) unless 'round' == cap
        element.add_attribute('curve', curve) unless  0 == curve
    end
end