Class: EagleCAD::Clearance
- Inherits:
-
Object
- Object
- EagleCAD::Clearance
- Defined in:
- lib/eaglecad/clearance.rb
Instance Attribute Summary collapse
-
#drill ⇒ Object
Returns the value of attribute drill.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, number) ⇒ Clearance
constructor
A new instance of Clearance.
- #to_xml ⇒ Object
Constructor Details
#initialize(name, number) ⇒ Clearance
Returns a new instance of Clearance.
17 18 19 20 21 |
# File 'lib/eaglecad/clearance.rb', line 17 def initialize(name, number) @name = name @number = number @values = [] end |
Instance Attribute Details
#drill ⇒ Object
Returns the value of attribute drill.
5 6 7 |
# File 'lib/eaglecad/clearance.rb', line 5 def drill @drill end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/eaglecad/clearance.rb', line 5 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/eaglecad/clearance.rb', line 5 def number @number end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
6 7 8 |
# File 'lib/eaglecad/clearance.rb', line 6 def values @values end |
#width ⇒ Object
Returns the value of attribute width.
5 6 7 |
# File 'lib/eaglecad/clearance.rb', line 5 def width @width end |
Class Method Details
.from_xml(element) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/eaglecad/clearance.rb', line 8 def self.from_xml(element) Clearance.new(element.attributes['name'], element.attributes['number'].to_i).tap do |clearance| clearance.width = (element.attributes['width'] || 0).to_f clearance.drill = (element.attributes['drill'] || 0).to_f element.elements.each {|element| clearance.values.push (element.text || 0).to_f } end end |
Instance Method Details
#to_xml ⇒ Object
24 25 26 27 28 29 |
# File 'lib/eaglecad/clearance.rb', line 24 def to_xml REXML::Element.new('class').tap do |element| element.add_attributes({'name' => name, 'number' => number, 'width' => width, 'drill' => drill}) values.each {|value| element.add_element('clearance', {'class' => number, 'value' => value})} end end |