Class: DXF::Parser
- Inherits:
-
Object
- Object
- DXF::Parser
- Defined in:
- lib/dxf/parser.rb
Constant Summary collapse
- ParseError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#entities ⇒ Array
The entities that comprise the drawing.
-
#header ⇒ Hash
The header variables.
Instance Method Summary collapse
-
#initialize(units = :mm) ⇒ Parser
constructor
A new instance of Parser.
- #parse(io) ⇒ Object
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
#entities ⇒ Array
Returns the entities that comprise the drawing.
9 10 11 |
# File 'lib/dxf/parser.rb', line 9 def entities @entities end |
#header ⇒ Hash
Returns 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 |