Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
Expand Down
40 changes: 40 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
GIT
remote: git://github.com/bfoz/sketch.git
revision: 1f7977e3f93d801a6a970e74508510055ed2e12e
specs:
sketch (0.4)
geometry (~> 6.4)

GIT
remote: git://github.com/bfoz/units-ruby.git
revision: e198cdb4e6978676b9e131ff8540b44aa7f57595
specs:
units (3.0.1)

PATH
remote: .
specs:
dxf (0.3.1)
geometry (~> 6.4)
sketch (~> 0.4)
units (~> 3.0)

GEM
remote: https://rubygems.org/
specs:
geometry (6.5)
minitest (5.9.0)
rake (11.2.2)

PLATFORMS
ruby

DEPENDENCIES
dxf!
minitest
rake
sketch!
units!

BUNDLED WITH
1.12.5
7 changes: 5 additions & 2 deletions lib/dxf/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Entity

attr_accessor :handle
attr_accessor :layer
attr_accessor :color_number

def self.new(type)
case type
Expand All @@ -30,9 +31,11 @@ def parse_pair(code, value)
# These are from the table that starts on page 70 of specification
case code
when '5'
handle = value
self.handle = value
when '8'
layer = value
self.layer = value
when '62'
self.color_number = value.to_i
else
p "Unrecognized entity group code: #{code} #{value}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dxf/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,4 @@ def to_entity
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/dxf/unparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ def unparse(output, sketch)
[0, 'EOF']).join("\n")
end
end
end
end
5 changes: 5 additions & 0 deletions test/dxf/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
circle = parser.entities.last
circle.must_be_instance_of(DXF::Circle)
circle.center.must_equal Geometry::Point[0,0]
circle.layer.must_equal '0'
circle.radius.must_equal 1
end

Expand All @@ -25,6 +26,7 @@
arc.radius.must_equal 1
arc.start_angle.must_equal 180.0
arc.end_angle.must_equal 270.0
arc.layer.must_equal '0'
end

it 'must parse a file with a translated circle' do
Expand All @@ -34,6 +36,7 @@
circle.must_be_instance_of(DXF::Circle)
circle.center.must_equal Geometry::Point[1,1]
circle.radius.must_equal 1
circle.layer.must_equal '0'
end

it 'must parse a file with a lightweight polyline' do
Expand All @@ -50,6 +53,8 @@
line.must_be_instance_of(DXF::Line)
line.first.must_equal Geometry::Point[0, 1]
line.last.must_equal Geometry::Point[0, 0]
parser.entities.first.layer.must_equal 'testing'
parser.entities.first.color_number.must_equal 254
end

it 'must parse a file with a spline' do
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/square_inches.dxf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENTITIES
0
LINE
8
0
testing
10
0
20
Expand All @@ -20,6 +20,8 @@ LINE
1
21
0
62
254
0
LINE
8
Expand Down Expand Up @@ -59,4 +61,4 @@ LINE
0
ENDSEC
0
EOF
EOF