class EagleCAD::Sheet::Instance
Attributes
attributes[R]
gate[RW]
origin[RW]
part[RW]
rotation[RW]
smashed[RW]
Public Class Methods
from_xml(element)
click to toggle source
# File lib/eaglecad/sheet.rb, line 48 def self.from_xml(element) Instance.new(element.attributes['part'], element.attributes['gate'], Geometry.point_from(element)).tap do |instance| element.attributes.each do |name, value| case name when 'smashed' then instance.smashed = ('no' != element.attributes['smashed']) when 'rot' then instance.rotation = element.attributes['rot'] when 'part', 'gate', 'x', 'y' # Ignore; already handled else raise StandardError, "Unrecognized Instance attribute '#{name}'" end end element.elements.each {|attribute| instance.attributes.push Attribute.from_xml(attribute) } end end
new(part, gate, origin)
click to toggle source
# File lib/eaglecad/sheet.rb, line 64 def initialize(part, gate, origin) @attributes = [] @part = part @gate = gate @origin = origin @smashed = false @rotation = 'R0' end
Public Instance Methods
to_xml()
click to toggle source
# File lib/eaglecad/sheet.rb, line 73 def to_xml REXML::Element.new('instance').tap do |element| element.add_attributes({'part' => part, 'gate' => gate, 'x' => origin.x, 'y' => origin.y}) element.add_attribute('smashed', 'yes') if smashed element.add_attribute('rot', rotation) attributes.each {|attribute| element.add_element attribute.to_xml } end end