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, Line

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.



12
13
14
# File 'lib/dxf/entity.rb', line 12

def handle
  @handle
end

#layerObject

Returns the value of attribute layer.



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

def layer
  @layer
end

Class Method Details

.new(type) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/dxf/entity.rb', line 15

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

Instance Method Details

#parse_pair(code, value) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dxf/entity.rb', line 24

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