Class: DXF::EntityParser
- Inherits:
-
Object
- Object
- DXF::EntityParser
- Defined in:
- lib/dxf/parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
-
#points ⇒ Array
Points.
Instance Method Summary collapse
-
#initialize(type_name) ⇒ EntityParser
constructor
A new instance of EntityParser.
- #parse_pair(code, value) ⇒ Object
- #to_entity ⇒ Object
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
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
150 151 152 |
# File 'lib/dxf/parser.rb', line 150 def handle @handle end |
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
151 152 153 |
# File 'lib/dxf/parser.rb', line 151 def layer @layer end |
#points ⇒ Array
Returns 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_entity ⇒ Object
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 |