Class: EagleCAD::Sheet::Label
- Inherits:
-
Object
- Object
- EagleCAD::Sheet::Label
- Defined in:
- lib/eaglecad/sheet.rb
Instance Attribute Summary collapse
-
#cross_reference ⇒ Object
Returns the value of attribute cross_reference.
-
#font ⇒ Object
Returns the value of attribute font.
-
#layer_number ⇒ Object
Returns the value of attribute layer_number.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#ratio ⇒ Object
Returns the value of attribute ratio.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#size ⇒ Object
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(origin, size, layer_number) ⇒ Label
constructor
A new instance of Label.
- #to_xml ⇒ Object
Constructor Details
#initialize(origin, size, layer_number) ⇒ Label
Returns a new instance of Label.
100 101 102 103 104 105 106 107 108 |
# File 'lib/eaglecad/sheet.rb', line 100 def initialize(origin, size, layer_number) @origin = origin @size = size @layer_number = layer_number @font = :proportional @ratio = 8 @rotation = 'R0' @cross_reference = false end |
Instance Attribute Details
#cross_reference ⇒ Object
Returns the value of attribute cross_reference.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def cross_reference @cross_reference end |
#font ⇒ Object
Returns the value of attribute font.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def font @font end |
#layer_number ⇒ Object
Returns the value of attribute layer_number.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def layer_number @layer_number end |
#origin ⇒ Object
Returns the value of attribute origin.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def origin @origin end |
#ratio ⇒ Object
Returns the value of attribute ratio.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def ratio @ratio end |
#rotation ⇒ Object
Returns the value of attribute rotation.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def rotation @rotation end |
#size ⇒ Object
Returns the value of attribute size.
85 86 87 |
# File 'lib/eaglecad/sheet.rb', line 85 def size @size end |
Class Method Details
.from_xml(element) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/eaglecad/sheet.rb', line 87 def self.from_xml(element) Label.new(Geometry.point_from(element), element.attributes['size'].to_f, element.attributes['layer'].to_i).tap do |label| element.attributes.each do |name, value| case name when 'font' then label.font = value.to_sym when 'ratio' then label.ratio = value.to_i when 'rot' then label.rotation = value when 'xref' then label.cross_reference = ('no' != value) end end end end |
Instance Method Details
#to_xml ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/eaglecad/sheet.rb', line 110 def to_xml REXML::Element.new('label').tap do |element| element.add_attributes({'x' => origin.x, 'y' => origin.y, 'layer' => layer_number ,'size' => size}) element.add_attribute('font', font) element.add_attribute('ratio', ratio) unless 8 == ratio element.add_attribute('rot', rotation) element.add_attribute('xref', cross_reference) if cross_reference end end |