Class: DXF::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/dxf/parser.rb

Constant Summary collapse

ParseError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(units = :mm) ⇒ Parser

Returns a new instance of Parser.



15
16
17
18
# File 'lib/dxf/parser.rb', line 15

def initialize(units=:mm)
    @entities = []
    @header = {}
end

Instance Attribute Details

#entitiesArray

Returns the entities that comprise the drawing.

Returns:

  • (Array)

    the entities that comprise the drawing



9
10
11
# File 'lib/dxf/parser.rb', line 9

def entities
  @entities
end

#headerHash

Returns the header variables.

Returns:

  • (Hash)

    the header variables



13
14
15
# File 'lib/dxf/parser.rb', line 13

def header
  @header
end

Instance Method Details

#parse(io) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/dxf/parser.rb', line 20

def parse(io)
    parse_pairs io do |code, value|
	raise ParseError, "DXF files must begin with group code 0, not #{code}" unless '0' == code
	raise ParseError, "Expecting a SECTION, not #{value}" unless 'SECTION' == value
	parse_section(io)
    end
    self
end