Class: Gerber::Aperture

Inherits:
Object
  • Object
show all
Defined in:
lib/gerber/aperture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Aperture

Returns a new instance of Aperture.

Raises:

  • (ArgumentError)


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

#holeObject

Returns the value of attribute hole.



9
10
11
# File 'lib/gerber/aperture.rb', line 9

def hole
  @hole
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/gerber/aperture.rb', line 8

def name
  @name
end

#parametersObject

Returns the value of attribute parameters.



9
10
11
# File 'lib/gerber/aperture.rb', line 9

def parameters
  @parameters
end

#rotationObject

Returns the value of attribute rotation.



9
10
11
# File 'lib/gerber/aperture.rb', line 9

def rotation
  @rotation
end

#shapeObject (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