Class: EagleCAD::Layer
- Inherits:
-
Object
- Object
- EagleCAD::Layer
- Defined in:
- lib/eaglecad/layer.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#color ⇒ Object
Returns the value of attribute color.
-
#fill ⇒ Object
Returns the value of attribute fill.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#visible ⇒ Object
Returns the value of attribute visible.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, number, color, fill) ⇒ Layer
constructor
A new instance of Layer.
- #to_xml ⇒ REXML::Element
Constructor Details
#initialize(name, number, color, fill) ⇒ Layer
Returns a new instance of Layer.
18 19 20 21 22 23 24 25 |
# File 'lib/eaglecad/layer.rb', line 18 def initialize(name, number, color, fill) @active = true @color = color @fill = fill @name = name @number = number @visible = true end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def active @active end |
#color ⇒ Object
Returns the value of attribute color.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def color @color end |
#fill ⇒ Object
Returns the value of attribute fill.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def fill @fill end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def number @number end |
#visible ⇒ Object
Returns the value of attribute visible.
5 6 7 |
# File 'lib/eaglecad/layer.rb', line 5 def visible @visible end |
Class Method Details
.from_xml(element) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/eaglecad/layer.rb', line 7 def self.from_xml(element) self.new(element.attributes['name'], element.attributes['number'], element.attributes['color'], element.attributes['fill']).tap do |layer| element.attributes.each do |name, value| case name when 'active' then layer.active = ('no' != value) when 'visible' then layer.visible = ('no' != value) end end end end |
Instance Method Details
#to_xml ⇒ REXML::Element
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/eaglecad/layer.rb', line 28 def to_xml element = REXML::Element.new 'layer' element.add_attributes({'number' => number, 'name' => name, 'color' => color, 'fill' => fill, }) element.add_attribute('active', active ? 'yes' : 'no') element.add_attribute('visible', visible ? 'yes' : 'no') element end |