Class: DXF::Entity

Inherits:
Object
  • Object
show all
Includes:
ClusterFactory
Defined in:
lib/dxf/entity.rb

Overview

Entity is the base class for everything that can live in the ENTITIES block

Direct Known Subclasses

Circle, LWPolyline, Line, Spline

Constant Summary collapse

TypeError =
Class.new(StandardError)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClusterFactory

included

Instance Attribute Details

#handleObject

Returns the value of attribute handle.



14
15
16
# File 'lib/dxf/entity.rb', line 14

def handle
  @handle
end

#layerObject

Returns the value of attribute layer.



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

def layer
  @layer
end

Class Method Details

.new(type) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/dxf/entity.rb', line 17

def self.new(type)
    case type
	when 'CIRCLE'	then Circle.new
	when 'LINE'	then Line.new
	when 'SPLINE'	then Spline.new
	else
	    raise TypeError, "Unrecognized entity type '#{type}'"
    end
end

Instance Method Details

#parse_pair(code, value) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dxf/entity.rb', line 27

def parse_pair(code, value)
    # Handle group codes that are common to all entities
    #  These are from the table that starts on page 70 of specification
    case code
	when '5'
	    handle = value
	when '8'
	    layer = value
	else
	    p "Unrecognized entity group code: #{code} #{value}"
    end
end