Class: DXF::EntityParser

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

Direct Known Subclasses

SplineParser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name) ⇒ EntityParser

Returns a new instance of EntityParser.



153
154
155
156
157
158
159
# File 'lib/dxf/parser.rb', line 153

def initialize(type_name)
    @flags = nil
    @points = Array.new { Point.new }
    @type_name = type_name

    @point_index = Hash.new {|h,k| h[k] = 0}
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



150
151
152
# File 'lib/dxf/parser.rb', line 150

def handle
  @handle
end

#layerObject (readonly)

Returns the value of attribute layer.



151
152
153
# File 'lib/dxf/parser.rb', line 151

def layer
  @layer
end

#pointsArray

Returns points.

Returns:

  • (Array)

    points



148
149
150
# File 'lib/dxf/parser.rb', line 148

def points
  @points
end

Instance Method Details

#parse_pair(code, value) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/dxf/parser.rb', line 161

def parse_pair(code, value)
    case code
	when 5 then	@handle = value		# Fixed
	when 8 then	@layer = value		# Fixed
	when 62 then	@color_number = value   # Fixed
	when 10, 20, 30
	    k = Parser.code_to_symbol(code)
	    i = @point_index[k]
	    @points[i] = Parser.update_point(@points[i], k => value)
	    @point_index[k] += 1
	when 70	then	@flags = value
    end
end

#to_entityObject



175
176
177
178
179
# File 'lib/dxf/parser.rb', line 175

def to_entity
    case @type_name
	when 'LWPOLYLINE' then LWPolyline.new(*points)
    end
end