Class: EagleCAD::Geometry::Circle

Inherits:
Geometry::Circle
  • Object
show all
Defined in:
lib/eaglecad/geometry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Circle

Returns a new instance of Circle.



18
19
20
21
# File 'lib/eaglecad/geometry.rb', line 18

def initialize(options={})
		@line_width = options.delete(:line_width)
		super options[:center], options[:radius]
end

Instance Attribute Details

#line_widthObject

Returns the value of attribute line_width.



10
11
12
# File 'lib/eaglecad/geometry.rb', line 10

def line_width
  @line_width
end

Class Method Details

.from_xml(element) ⇒ Object

Create a EagleCAD::Geometry::Circle from an REXML::Element

Parameters:

  • element (Element)

    The REXML::Element to parse



14
15
16
# File 'lib/eaglecad/geometry.rb', line 14

def self.from_xml(element)
		self.new center:Geometry.point_from(element, 'x', 'y'), radius:element.attributes['radius'].to_f, line_width:element.attributes['width'].to_f
end

Instance Method Details

#to_xmlREXML::Element

Returns:

  • (REXML::Element)


24
25
26
# File 'lib/eaglecad/geometry.rb', line 24

def to_xml
		REXML::Element.new('circle').tap {|element| element.add_attributes({'x' => Geometry.format(center.x), 'y' => Geometry.format(center.y), 'radius' => Geometry.format(radius), 'width' => line_width}) }
end