Class: Gerber

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

Overview

An Aperture definition for an Extended Gerber file

Defined Under Namespace

Classes: Aperture, Layer, Parser

Constant Summary collapse

ParseError =
Class.new(StandardError)
Arc =
Geometry::Arc
Line =
Geometry::Line
Point =
Geometry::Point

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGerber

Returns a new instance of Gerber.



20
21
22
23
24
25
# File 'lib/gerber.rb', line 20

def initialize
	@apertures = []
	@layers = []
	@polarity = :positive
	@units = nil
end

Instance Attribute Details

#aperturesObject (readonly)

Returns the value of attribute apertures.



18
19
20
# File 'lib/gerber.rb', line 18

def apertures
  @apertures
end

#decimal_placesObject

Returns the value of attribute decimal_places.



15
16
17
# File 'lib/gerber.rb', line 15

def decimal_places
  @decimal_places
end

#integer_placesObject

Returns the value of attribute integer_places.



15
16
17
# File 'lib/gerber.rb', line 15

def integer_places
  @integer_places
end

#layersObject (readonly)

Returns the value of attribute layers.



18
19
20
# File 'lib/gerber.rb', line 18

def layers
  @layers
end

#zero_omissionObject

Returns the value of attribute zero_omission.



16
17
18
# File 'lib/gerber.rb', line 16

def zero_omission
  @zero_omission
end

Class Method Details

.read(filename) ⇒ Gerber

Read and parse the given file into a Gerber object

Returns:

  • (Gerber)

    The resulting Gerber object, or nil on failure



36
37
38
39
40
# File 'lib/gerber.rb', line 36

def self.read(filename)
	File.open(filename) do |f|
 Gerber::Parser.new.parse(f)
	end
end

.write(filename, container) ⇒ Object



42
43
# File 'lib/gerber.rb', line 42

def self.write(filename, container)
end

Instance Method Details

#coordinate_format=(*args) ⇒ Object

Set the format used for coordinates

Parameters:

  • integer_places (Number)

    The number of digits to the left of the decimal point

  • decimal_places (Number)

    The number of digits to the right of the decimal point



30
31
32
# File 'lib/gerber.rb', line 30

def coordinate_format=(*args)
	self.integer_places, self.decimal_places = args.flatten.map {|a| a.to_i }
end