Class: Gerber::Aperture
- Inherits:
-
Object
- Object
- Gerber::Aperture
- Defined in:
- lib/gerber/aperture.rb
Instance Attribute Summary collapse
-
#hole ⇒ Object
Returns the value of attribute hole.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#rotation ⇒ Object
Returns the value of attribute rotation.
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(parameters) ⇒ Aperture
constructor
A new instance of Aperture.
Constructor Details
#initialize(parameters) ⇒ Aperture
Returns a new instance of Aperture.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gerber/aperture.rb', line 11 def initialize(parameters) raise ArgumentError unless parameters.is_a? Hash if parameters.has_key? :circle @shape = Geometry::Circle.new [0,0], :diameter => parameters[:circle] parameters.delete :circle elsif parameters.has_key? :obround @shape = Geometry::Obround.new [0,0], parameters[:obround] parameters.delete :obround elsif parameters.has_key? :polygon @shape = Geometry::RegularPolygon.new parameters[:sides], [0,0], :diameter => parameters[:polygon] parameters.delete :polygon elsif parameters.has_key? :rectangle @shape = Geometry::Rectangle.new [0,0], parameters[:rectangle] parameters.delete :rectangle end parameters.each {|k| self.instance_variable_set("@#{k.first}", k.last) } end |
Instance Attribute Details
#hole ⇒ Object
Returns the value of attribute hole.
9 10 11 |
# File 'lib/gerber/aperture.rb', line 9 def hole @hole end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/gerber/aperture.rb', line 8 def name @name end |
#parameters ⇒ Object
Returns the value of attribute parameters.
9 10 11 |
# File 'lib/gerber/aperture.rb', line 9 def parameters @parameters end |
#rotation ⇒ Object
Returns the value of attribute rotation.
9 10 11 |
# File 'lib/gerber/aperture.rb', line 9 def rotation @rotation end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
8 9 10 |
# File 'lib/gerber/aperture.rb', line 8 def shape @shape end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/gerber/aperture.rb', line 30 def ==(other) (self.hole == other.hole) && (self.parameters == other.parameters) && (self.rotation == other.rotation) && (self.shape == other.shape) end |