Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Block
- def initialize(name, coords)
- @name = name
- @x1, @y1, @z1 = coords[1]
- @x2, @y2, @z2 = coords[0]
- end
- def to_s
- "{ #{@x1}, #{@y1}, #{@z1}, #{@x2}, #{@y2}, #{@z2} }, -- #{@name}"
- end
- end
- name = nil
- num = 0
- coords = []
- File.open(ARGV[0]).read.each_line do |line|
- if name
- if line =~ /^v ([-0-9.]+) ([-0-9.]+) ([-0-9.]+)/
- if num == 2 || num == 4
- coords << [$1, $2, $3]
- end
- if num == 4
- puts Block.new(name.strip, coords)
- name = nil
- end
- num += 1
- end
- end
- if line =~ /^o (.*)/
- name = $1
- num = 0
- coords = []
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement